Skip to content

Commit

Permalink
[Refactor] use globalThis if available
Browse files Browse the repository at this point in the history
Closes #12
  • Loading branch information
JounQin authored and ljharb committed Aug 31, 2021
1 parent 9401fb5 commit 8160fbc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
"root": true,

"extends": "@ljharb",

"globals": {
"globalThis": false
}
}
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ var possibleNames = [
'Uint8ClampedArray'
];

var g = typeof globalThis === 'undefined' ? global : globalThis;

module.exports = function availableTypedArrays() {
var out = [];
for (var i = 0; i < possibleNames.length; i++) {
if (typeof global[possibleNames[i]] === 'function') {
if (typeof g[possibleNames[i]] === 'function') {
out[out.length] = possibleNames[i];
}
}
Expand Down

0 comments on commit 8160fbc

Please sign in to comment.