Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sindresorhus/globals
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 890bcfe6e052739ce2d4dea038589f9243cf9b17
Choose a base ref
...
head repository: sindresorhus/globals
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 47d4224894e1a6cda1a6b19920846e7141151aca
Choose a head ref
Loading
Showing with 1,063 additions and 404 deletions.
  1. +1 −2 .gitattributes
  2. +3 −0 .github/security.md
  3. +22 −0 .github/workflows/main.yml
  4. +1 −0 .gitignore
  5. +1 −0 .npmrc
  6. +0 −5 .travis.yml
  7. +75 −0 get-browser-globals.js
  8. +839 −134 globals.json
  9. +6 −0 index.d.ts
  10. +7 −0 index.test-d.ts
  11. +1 −1 license
  12. +0 −211 package-lock.json
  13. +54 −33 package.json
  14. +15 −12 readme.md
  15. +38 −6 test.js
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
* text=auto
*.js text eol=lf
* text=auto eol=lf
3 changes: 3 additions & 0 deletions .github/security.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Security Policy

To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
22 changes: 22 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CI
on:
- push
- pull_request
jobs:
test:
name: Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version:
- 14
- 12
- 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
yarn.lock
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

75 changes: 75 additions & 0 deletions get-browser-globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
'use strict';

const ignorePatterns = [
/^webkit/i,
'BeforeInstallPromptEvent',
/^Bluetooth/,
'CDATASection',
'captureEvents',
'InputDeviceCapabilities',
'releaseEvents',
'SyncManager',
/^USB/,

// DevTools globals
'chrome',
'$_',
'$0',
'$1',
'$2',
'$3',
'$4',
'$',
'$$',
'$x',
'clear',
'copy',
'debug',
'dir',
'dirxml',
'getEventListeners',
'inspect',
'keys',
'monitor',
'monitorEvents',
'profile',
'profileEnd',
'queryObjects',
'table',
'undebug',
'unmonitor',
'unmonitorEvents',
'values'
];

const globals = Object.getOwnPropertyNames(window)
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
.filter(global => {
for (const pattern of ignorePatterns) {
if (typeof pattern === 'string') {
if (global === pattern) {
return false;
}
} else {
if (pattern.test(global)) {
return false;
}
}
}

return true;
});

const ret = {};
for (const key of globals) {
ret[key] = key.startsWith('on');
}

copy(JSON.stringify(ret, null, '\t'));

/*
Usage:
Open an Incognito window in Chrome Canary and paste the above into the console. You'll now have a new object in your clipboard for the `browser` field in `globals.json`. You still need to manually filter out items from the `builtin` list.
*/
Loading