From bbff7403fbf46f9ad92240ac213df8d30ef31b64 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 20 Sep 2018 02:56:13 +0200 Subject: update packages --- node_modules/timers-browserify/main.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'node_modules/timers-browserify/main.js') diff --git a/node_modules/timers-browserify/main.js b/node_modules/timers-browserify/main.js index 001c63190..4214e74bc 100644 --- a/node_modules/timers-browserify/main.js +++ b/node_modules/timers-browserify/main.js @@ -1,12 +1,15 @@ +var scope = (typeof global !== "undefined" && global) || + (typeof self !== "undefined" && self) || + window; var apply = Function.prototype.apply; // DOM APIs, for completeness exports.setTimeout = function() { - return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); + return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout); }; exports.setInterval = function() { - return new Timeout(apply.call(setInterval, window, arguments), clearInterval); + return new Timeout(apply.call(setInterval, scope, arguments), clearInterval); }; exports.clearTimeout = exports.clearInterval = function(timeout) { @@ -21,7 +24,7 @@ function Timeout(id, clearFn) { } Timeout.prototype.unref = Timeout.prototype.ref = function() {}; Timeout.prototype.close = function() { - this._clearFn.call(window, this._id); + this._clearFn.call(scope, this._id); }; // Does not start the time, just sets up the members needed. @@ -49,5 +52,12 @@ exports._unrefActive = exports.active = function(item) { // setimmediate attaches itself to the global object require("setimmediate"); -exports.setImmediate = setImmediate; -exports.clearImmediate = clearImmediate; +// On some exotic environments, it's not clear which object `setimmediate` was +// able to install onto. Search each possibility in the same order as the +// `setimmediate` library. +exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) || + (typeof global !== "undefined" && global.setImmediate) || + (this && this.setImmediate); +exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) || + (typeof global !== "undefined" && global.clearImmediate) || + (this && this.clearImmediate); -- cgit v1.2.3