'use strict';

var setImmediate$1 = require('../../../_virtual/setImmediate.js');

Object.defineProperty(setImmediate$1.__exports, "__esModule", {
    value: true
});
setImmediate$1.__exports.fallback = fallback;
setImmediate$1.__exports.wrap = wrap;
/* istanbul ignore file */

var hasQueueMicrotask = setImmediate$1.__exports.hasQueueMicrotask = typeof queueMicrotask === 'function' && queueMicrotask;
var hasSetImmediate = setImmediate$1.__exports.hasSetImmediate = typeof setImmediate === 'function' && setImmediate;
var hasNextTick = setImmediate$1.__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;
}

setImmediate$1.__exports.default = wrap(_defer);
