2016-10-10 03:43:44 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
value: true
|
|
|
|
});
|
|
|
|
exports.hasNextTick = exports.hasSetImmediate = undefined;
|
|
|
|
exports.fallback = fallback;
|
|
|
|
exports.wrap = wrap;
|
|
|
|
|
2016-11-03 01:33:53 +01:00
|
|
|
var _baseRest = require('lodash/_baseRest');
|
2016-10-10 03:43:44 +02:00
|
|
|
|
2016-11-03 01:33:53 +01:00
|
|
|
var _baseRest2 = _interopRequireDefault(_baseRest);
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
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) {
|
2016-11-03 01:33:53 +01:00
|
|
|
return (0, _baseRest2.default)(function (fn, args) {
|
2016-10-10 03:43:44 +02:00
|
|
|
defer(function () {
|
|
|
|
fn.apply(null, args);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
var _defer;
|
|
|
|
|
|
|
|
if (hasSetImmediate) {
|
|
|
|
_defer = setImmediate;
|
|
|
|
} else if (hasNextTick) {
|
|
|
|
_defer = process.nextTick;
|
|
|
|
} else {
|
|
|
|
_defer = fallback;
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.default = wrap(_defer);
|