Skip to content

Commit

Permalink
Increase compatiblity with sinon.useFakeTimers()
Browse files Browse the repository at this point in the history
By caching reference to the global setImmediate and setTimeout we can ensure
that promise-polyfill still works as excpected when sinon.useFakeTimers()
replaces them with fake versions.
  • Loading branch information
Morgan Roderick committed Jan 8, 2016
1 parent 7ee8e28 commit 235ab1f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Promise.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(function(root) {

var setTimeout = root.setTimeout;

// Use polyfill for setImmediate for performance gains
var asap = (typeof setImmediate === 'function' && setImmediate) ||
function(fn) { setTimeout(fn, 1); };
Expand Down Expand Up @@ -187,4 +189,4 @@
root.Promise = Promise;
}

})(this);
})(global || this);

0 comments on commit 235ab1f

Please sign in to comment.