You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
857 B
34 lines
857 B
2 years ago
|
'use strict';
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", {
|
||
|
value: true
|
||
|
});
|
||
|
exports.fallback = fallback;
|
||
|
exports.wrap = wrap;
|
||
|
/* istanbul ignore file */
|
||
|
|
||
|
var hasQueueMicrotask = exports.hasQueueMicrotask = typeof queueMicrotask === 'function' && queueMicrotask;
|
||
|
var hasSetImmediate = exports.hasSetImmediate = typeof setImmediate === 'function' && setImmediate;
|
||
|
var hasNextTick = exports.hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function';
|
||
|
|
||
|
function fallback(fn) {
|
||
|
setTimeout(fn, 0);
|
||
|
}
|
||
|
|
||
|
function wrap(defer) {
|
||
|
return (fn, ...args) => defer(() => fn(...args));
|
||
|
}
|
||
|
|
||
|
var _defer;
|
||
|
|
||
|
if (hasQueueMicrotask) {
|
||
|
_defer = queueMicrotask;
|
||
|
} else if (hasSetImmediate) {
|
||
|
_defer = setImmediate;
|
||
|
} else if (hasNextTick) {
|
||
|
_defer = process.nextTick;
|
||
|
} else {
|
||
|
_defer = fallback;
|
||
|
}
|
||
|
|
||
|
exports.default = wrap(_defer);
|