Support browsers who do not support setImmediate #264
Conversation
|
|
| setImmediate || setTimeout; | ||
| typeof setImmediate === 'function' ? | ||
| setImmediate : | ||
| fn => { setTimeout(fn, 0); }; |
nanto
Mar 14, 2021
Author
At first I wrote as following but it caused error on test.
typeof setImmediate === 'function' ? setImmediate : setTimeout;
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ src/index.js:401:12
Cannot return enqueuePostPromiseJob because TimeoutID [1] is incompatible with
undefined [2] in the return value.
src/index.js
[2] 398│ ): (() => void) => void {
399│ var batchScheduleFn = options && options.batchScheduleFn;
400│ if (batchScheduleFn === undefined) {
401│ return enqueuePostPromiseJob;
402│ }
403│ if (typeof batchScheduleFn !== 'function') {
404│ throw new TypeError(
/tmp/flow/flowlib_20a9f9de/core.js
[1] 819│ ): TimeoutID;
At first I wrote as following but it caused error on test.
typeof setImmediate === 'function' ? setImmediate : setTimeout;Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ src/index.js:401:12
Cannot return enqueuePostPromiseJob because TimeoutID [1] is incompatible with
undefined [2] in the return value.
src/index.js
[2] 398│ ): (() => void) => void {
399│ var batchScheduleFn = options && options.batchScheduleFn;
400│ if (batchScheduleFn === undefined) {
401│ return enqueuePostPromiseJob;
402│ }
403│ if (typeof batchScheduleFn !== 'function') {
404│ throw new TypeError(
/tmp/flow/flowlib_20a9f9de/core.js
[1] 819│ ): TimeoutID;
| @@ -239,7 +239,9 @@ var enqueuePostPromiseJob = | |||
| process.nextTick(fn); | |||
| }); | |||
| } : | |||
| setImmediate || setTimeout; | |||
| typeof setImmediate === 'function' ? | |||
| fn => { setImmediate(fn); } : | |||
nanto
Mar 14, 2021
•
Author
IE 11 throws "Invalid calling object" error if the receiver of setImmediate is not a window.
var o = { m: setImmediate }; o.m(function () { console.log('ok'); });
// => "Invalid calling object" error in IE 11
IE 11 throws "Invalid calling object" error if the receiver of setImmediate is not a window.
var o = { m: setImmediate }; o.m(function () { console.log('ok'); });
// => "Invalid calling object" error in IE 11
Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

This pull request allows browsers who don't support
setImmediateto fallback tosetTimeout.Fixes #249