Skip to content

Commit

Permalink
Stop evaluating Date.now() dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
pittst3r committed Dec 6, 2016
1 parent b9fbb2b commit 1e0d68a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/backburner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
isString,
isFunction,
isNumber,
isCoercableNumber
isCoercableNumber,
now
} from './utils';

import searchTimer from './binary-search';
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions lib/backburner/utils.js
Original file line number Diff line number Diff line change
@@ -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]);
Expand Down

0 comments on commit 1e0d68a

Please sign in to comment.