-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #742 from streamich/fix-global
fix: 🐛 use globalThis defensively
- Loading branch information
Showing
4 changed files
with
10 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
type TSetImmediate = (callback: (...args) => void, args?) => void; | ||
let _setImmediate: TSetImmediate; | ||
|
||
if (typeof setImmediate === 'function') _setImmediate = setImmediate.bind(globalThis); | ||
else _setImmediate = setTimeout.bind(globalThis); | ||
if (typeof setImmediate === 'function') _setImmediate = setImmediate.bind(typeof globalThis !== 'undefined' ? globalThis : global); | ||
else _setImmediate = setTimeout.bind(typeof globalThis !== 'undefined' ? globalThis : global); | ||
|
||
export default _setImmediate as TSetImmediate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters