forked from caolan/async
-
Notifications
You must be signed in to change notification settings - Fork 2
/
timing.js
32 lines (30 loc) · 894 Bytes
/
timing.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
var timing = module.exports = {};
//// nextTick implementation with browser-compatible fallback ////
if ( typeof process === 'undefined' || !( process.nextTick ) ) {
if ( typeof setImmediate === 'function' ) {
timing.nextTick = function( fn ) {
// not a direct alias for IE10 compatibility
setImmediate( fn );
};
timing.setImmediate = timing.nextTick;
}
else {
timing.nextTick = function( fn ) {
setTimeout( fn, 0 );
};
timing.setImmediate = timing.nextTick;
}
}
else {
timing.nextTick = process.nextTick;
if ( typeof setImmediate !== 'undefined' ) {
timing.setImmediate = function( fn ) {
// not a direct alias for IE10 compatibility
setImmediate( fn );
};
}
else {
timing.setImmediate = timing.nextTick;
}
}