forked from inexorabletash/polyfill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
timing.js
31 lines (26 loc) · 790 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
(function(global) {
if (!('window' in global && 'document' in global))
return;
//----------------------------------------------------------------------
//
// Efficient Script Yielding
// http://w3c.github.io/setImmediate/
// (Not widely adopted.)
//
//----------------------------------------------------------------------
(function() {
if ('setImmediate' in global)
return;
function setImmediate(callback/*, args*/) {
var params = [].slice.call(arguments, 1);
return global.setTimeout(function() {
callback.apply(null, params);
}, 0);
}
function clearImmediate(handle) {
global.clearTimeout(handle);
}
global.setImmediate = setImmediate;
global.clearImmediate = clearImmediate;
}());
}(this));