diff --git a/lib/backburner/index.js b/lib/backburner/index.js index 1710742e..11e05bc0 100644 --- a/lib/backburner/index.js +++ b/lib/backburner/index.js @@ -3,7 +3,8 @@ import { isString, isFunction, isNumber, - isCoercableNumber + isCoercableNumber, + now } from './utils'; import searchTimer from './binary-search'; @@ -379,7 +380,7 @@ Backburner.prototype = { } } - var executeAt = Date.now() + parseInt(wait !== wait ? 0 : wait, 10); + var executeAt = now() + parseInt(wait !== wait ? 0 : wait, 10); if (isString(method)) { method = target[method]; @@ -586,7 +587,7 @@ Backburner.prototype = { }, _scheduleExpiredTimers: function () { - var n = Date.now(); + var n = now(); var timers = this._timers; var i = 0; var l = timers.length; @@ -621,7 +622,7 @@ Backburner.prototype = { return; } var minExpiresAt = this._timers[0]; - var n = Date.now(); + var n = now(); var wait = Math.max(0, minExpiresAt - n); this._timerTimeoutId = this._platform.setTimeout(this._boundRunExpiredTimers, wait); } diff --git a/lib/backburner/utils.js b/lib/backburner/utils.js index c12788c5..6a979a21 100644 --- a/lib/backburner/utils.js +++ b/lib/backburner/utils.js @@ -1,5 +1,7 @@ var NUMBER = /\d+/; +export var now = Date.now; + export function each(collection, callback) { for (var i = 0; i < collection.length; i++) { callback(collection[i]);