massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / modules / web.timers.js
1 var $ = require('../internals/export');
2 var global = require('../internals/global');
3 var apply = require('../internals/function-apply');
4 var isCallable = require('../internals/is-callable');
5 var userAgent = require('../internals/engine-user-agent');
6 var arraySlice = require('../internals/array-slice');
7
8 var MSIE = /MSIE .\./.test(userAgent); // <- dirty ie9- check
9 var Function = global.Function;
10
11 var wrap = function (scheduler) {
12   return function (handler, timeout /* , ...arguments */) {
13     var boundArgs = arguments.length > 2;
14     var args = boundArgs ? arraySlice(arguments, 2) : undefined;
15     return scheduler(boundArgs ? function () {
16       apply(isCallable(handler) ? handler : Function(handler), this, args);
17     } : handler, timeout);
18   };
19 };
20
21 // ie9- setTimeout & setInterval additional parameters fix
22 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
23 $({ global: true, bind: true, forced: MSIE }, {
24   // `setTimeout` method
25   // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
26   setTimeout: wrap(global.setTimeout),
27   // `setInterval` method
28   // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval
29   setInterval: wrap(global.setInterval)
30 });