summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/async.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/async.js b/lib/async.js
index bbb3495..1e76ee8 100644
--- a/lib/async.js
+++ b/lib/async.js
@@ -112,11 +112,18 @@
//// exported async module functions ////
//// nextTick implementation with browser-compatible fallback ////
+
+ // capture the global reference to guard against fakeTimer mocks
+ var _setImmediate;
+ if (typeof setImmediate === 'function') {
+ _setImmediate = setImmediate;
+ }
+
if (typeof process === 'undefined' || !(process.nextTick)) {
- if (typeof setImmediate === 'function') {
+ if (_setImmediate) {
async.nextTick = function (fn) {
// not a direct alias for IE10 compatibility
- setImmediate(fn);
+ _setImmediate(fn);
};
async.setImmediate = async.nextTick;
}
@@ -129,10 +136,10 @@
}
else {
async.nextTick = process.nextTick;
- if (typeof setImmediate !== 'undefined') {
+ if (_setImmediate) {
async.setImmediate = function (fn) {
// not a direct alias for IE10 compatibility
- setImmediate(fn);
+ _setImmediate(fn);
};
}
else {