aboutsummaryrefslogtreecommitdiff
path: root/node_modules/timers-browserify/main.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
commitbbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch)
treec58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/timers-browserify/main.js
parent003fb34971cf63466184351b4db5f7c67df4f444 (diff)
update packages
Diffstat (limited to 'node_modules/timers-browserify/main.js')
-rw-r--r--node_modules/timers-browserify/main.js20
1 files changed, 15 insertions, 5 deletions
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);