1 |
3a515b92
|
cagy
|
'use strict';
|
2 |
|
|
|
3 |
|
|
Object.defineProperty(exports, "__esModule", {
|
4 |
|
|
value: true
|
5 |
|
|
});
|
6 |
|
|
|
7 |
|
|
var _setImmediate = require('./internal/setImmediate');
|
8 |
|
|
|
9 |
|
|
/**
|
10 |
|
|
* Calls `callback` on a later loop around the event loop. In Node.js this just
|
11 |
|
|
* calls `process.nextTick`. In the browser it will use `setImmediate` if
|
12 |
|
|
* available, otherwise `setTimeout(callback, 0)`, which means other higher
|
13 |
|
|
* priority events may precede the execution of `callback`.
|
14 |
|
|
*
|
15 |
|
|
* This is used internally for browser-compatibility purposes.
|
16 |
|
|
*
|
17 |
|
|
* @name nextTick
|
18 |
|
|
* @static
|
19 |
|
|
* @memberOf module:Utils
|
20 |
|
|
* @method
|
21 |
|
|
* @see [async.setImmediate]{@link module:Utils.setImmediate}
|
22 |
|
|
* @category Util
|
23 |
|
|
* @param {Function} callback - The function to call on a later loop around
|
24 |
|
|
* the event loop. Invoked with (args...).
|
25 |
|
|
* @param {...*} args... - any number of additional arguments to pass to the
|
26 |
|
|
* callback on the next tick.
|
27 |
|
|
* @example
|
28 |
|
|
*
|
29 |
|
|
* var call_order = [];
|
30 |
|
|
* async.nextTick(function() {
|
31 |
|
|
* call_order.push('two');
|
32 |
|
|
* // call_order now equals ['one','two']
|
33 |
|
|
* });
|
34 |
|
|
* call_order.push('one');
|
35 |
|
|
*
|
36 |
|
|
* async.setImmediate(function (a, b, c) {
|
37 |
|
|
* // a, b, and c equal 1, 2, and 3
|
38 |
|
|
* }, 1, 2, 3);
|
39 |
|
|
*/
|
40 |
|
|
var _defer;
|
41 |
|
|
|
42 |
|
|
if (_setImmediate.hasNextTick) {
|
43 |
|
|
_defer = process.nextTick;
|
44 |
|
|
} else if (_setImmediate.hasSetImmediate) {
|
45 |
|
|
_defer = setImmediate;
|
46 |
|
|
} else {
|
47 |
|
|
_defer = _setImmediate.fallback;
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
exports.default = (0, _setImmediate.wrap)(_defer);
|
51 |
|
|
module.exports = exports['default'];
|