Skip to content

Commit

Permalink
fix: add setImmediate.bind
Browse files Browse the repository at this point in the history
Fixes the following issue when attempted in a browser under some
circumstances where `this !== global`:

```
Uncaught TypeError: Illegal invocation
    at Volume.wrapAsync (index-bundle.js:8692)
    at Volume.stat (index-bundle.js:9261)
```
  • Loading branch information
opichals committed Sep 28, 2018
1 parent 21f6bdc commit ceb777d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/setImmediate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ type TSetImmediate = (callback: (...args) => void, args?) => void;
let _setImmediate: TSetImmediate;

/* istanbul ignore next */
if(typeof setImmediate === 'function') _setImmediate = setImmediate;
if(typeof setImmediate === 'function') _setImmediate = setImmediate.bind(global);
/* istanbul ignore next */
else _setImmediate = setTimeout;
else _setImmediate = setTimeout.bind(global);

export default _setImmediate as TSetImmediate;

0 comments on commit ceb777d

Please sign in to comment.