Skip to content

Commit

Permalink
Up version
Browse files Browse the repository at this point in the history
  • Loading branch information
cjohansen committed Feb 25, 2017
1 parent bd1d19f commit 71ba6ed
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
40 changes: 21 additions & 19 deletions lolex.js
Expand Up @@ -46,8 +46,10 @@ function parseTime(str) {
}

var strings = str.split(":");
var l = strings.length, i = l;
var ms = 0, parsed;
var l = strings.length;
var i = l;
var ms = 0;
var parsed;

if (l > 3 || !/^(\d\d:){0,2}\d\d?$/.test(str)) {
throw new Error("tick only understands numbers, 'm:s' and 'h:m:s'. Each part must be two digits");
Expand Down Expand Up @@ -225,10 +227,9 @@ function compareTimers(a, b) {
}

function firstTimerInRange(clock, from, to) {
var timers = clock.timers,
timer = null,
id,
isInRange;
var timers = clock.timers;
var timer = null;
var id, isInRange;

for (id in timers) {
if (timers.hasOwnProperty(id)) {
Expand All @@ -244,9 +245,9 @@ function firstTimerInRange(clock, from, to) {
}

function firstTimer(clock) {
var timers = clock.timers,
timer = null,
id;
var timers = clock.timers;
var timer = null;
var id;

for (id in timers) {
if (timers.hasOwnProperty(id)) {
Expand All @@ -260,9 +261,9 @@ function firstTimer(clock) {
}

function lastTimer(clock) {
var timers = clock.timers,
timer = null,
id;
var timers = clock.timers;
var timer = null;
var id;

for (id in timers) {
if (timers.hasOwnProperty(id)) {
Expand Down Expand Up @@ -410,8 +411,8 @@ if (hrtimePresent) {
}

var keys = Object.keys || function (obj) {
var ks = [],
key;
var ks = [];
var key;

for (key in obj) {
if (obj.hasOwnProperty(key)) {
Expand Down Expand Up @@ -476,17 +477,18 @@ function createClock(now, loopLimit) {

clock.tick = function tick(ms) {
ms = typeof ms === "number" ? ms : parseTime(ms);
var tickFrom = clock.now, tickTo = clock.now + ms, previous = clock.now;
var tickFrom = clock.now;
var tickTo = clock.now + ms;
var previous = clock.now;
var timer = firstTimerInRange(clock, tickFrom, tickTo);
var oldNow;
var oldNow, firstException;

clock.duringTick = true;

function updateHrTime(newNow) {
clock.hrNow += (newNow - clock.now);
}

var firstException;
while (timer && tickFrom <= tickTo) {
if (clock.timers[timer.id]) {
updateHrTime(timer.callAt);
Expand Down Expand Up @@ -568,9 +570,9 @@ function createClock(now, loopLimit) {
clock.timers = {};
};

clock.setSystemTime = function setSystemTime(now) {
clock.setSystemTime = function setSystemTime(systemTime) {
// determine time difference
var newNow = getEpoch(now);
var newNow = getEpoch(systemTime);
var difference = newNow - clock.now;
var id, timer;

Expand Down
8 changes: 4 additions & 4 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "lolex",
"description": "Fake JavaScript timers",
"version": "1.5.2",
"version": "1.6.0",
"homepage": "http://github.com/sinonjs/lolex",
"author": "Christian Johansen",
"repository": {
Expand All @@ -23,12 +23,12 @@
"prepublish": "npm run bundle"
},
"devDependencies": {
"browserify": "^13.0.1",
"browserify": "^14.1.0",
"eslint": "^3.16.1",
"eslint-config-sinon": "^1.0.0",
"eslint-plugin-mocha": "^4.8.0",
"mocha": "^3.1.2",
"mochify": "^2.18.0",
"mocha": "^3.2.0",
"mochify": "^3.0.0",
"referee": "^1.2.0",
"sinon": "^1.17.4"
},
Expand Down

0 comments on commit 71ba6ed

Please sign in to comment.