Skip to content

Commit

Permalink
Prepare for new release
Browse files Browse the repository at this point in the history
  • Loading branch information
fatso83 committed Jul 13, 2017
1 parent ce3e35c commit 152f841
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 31 deletions.
13 changes: 9 additions & 4 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
Christian Johansen <christian@cjohansen.no>
Carl-Erik Kopseng <carlerik@gmail.com>
Christian Johansen <christian@cjohansen.no>
Morgan Roderick <morgan@roderick.dk>
Maximilian Antoni <mail@maxantoni.de>
Mark Wubben <mark@novemberborn.net>
Soutaro Matsumoto <matsumoto@soutaro.com>
Duncan Beevers <duncan@dweebd.com>
Soutaro Matsumoto <matsumoto@soutaro.com>
Rogier Schouten <github@workingcode.ninja>
Karl O'Keeffe <karl@geckoboard.com>
Thibault Hild <gautaz@users.noreply.github.com>
Clark Tomlinson <fallen013@gmail.com>
Josh Goldberg <joshuakgoldberg@outlook.com>
Andy Edwards <jedwards@fastmail.com>
Benjamin Gruenbaum <inglor@gmail.com>
Curtis M. Humphrey, Ph.D <curtis@createdwithflair.com>
Kyle Fleming <kyle@kylefleming.net>
Mark Banner <standard8@mozilla.com>
Nando <fdanko@ekumenlabs.com>
Simen Bekkhus <sbekkhus91@gmail.com>
Sylvain Fraïssé <fraisse.sylvain@gmail.com>
Andy Edwards <jedwards@fastmail.com>
Thibault Hild <gautaz@users.noreply.github.com>
23 changes: 23 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@

v2.0.0 / 2017-07-13
==================

* New install() signature
* Add support for performance.now (#106)
* Fix issue with tick(): setSystemClock then throw
* Update old dependencies

v1.6.0 / 2017-02-25
===================

* Use common Sinon.JS eslint config
* Allow install to be called with date object
* Remove wrapper function
* Fixed typo in clock.runAll error

v1.5.2 / 2016-11-10
===================

* Upgrade mocha to latest
* Only overwrite globals when running in IE

1.5.1 / 2016-07-26
==================

Expand Down
53 changes: 26 additions & 27 deletions lolex.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function fixedModulo(n, m) {

/**
* Used to grok the `now` parameter to createClock.
* @param epoch {Date|number} the system time
*/
function getEpoch(epoch) {
if (!epoch) { return 0; }
Expand Down Expand Up @@ -431,6 +432,10 @@ var keys = Object.keys || function (obj) {

exports.timers = timers;

/**
* @param now {Date|number} the system time
* @param loopLimit {number} maximum number of timers that will be run when calling runAll()
*/
function createClock(now, loopLimit) {
loopLimit = loopLimit || 1000;

Expand Down Expand Up @@ -503,15 +508,16 @@ function createClock(now, loopLimit) {
try {
oldNow = clock.now;
callTimer(clock, timer);
// compensate for any setSystemTime() call during timer callback
if (oldNow !== clock.now) {
tickFrom += clock.now - oldNow;
tickTo += clock.now - oldNow;
previous += clock.now - oldNow;
}
} catch (e) {
firstException = firstException || e;
}

// compensate for any setSystemTime() call during timer callback
if (oldNow !== clock.now) {
tickFrom += clock.now - oldNow;
tickTo += clock.now - oldNow;
previous += clock.now - oldNow;
}
}

timer = firstTimerInRange(clock, previous, tickTo);
Expand Down Expand Up @@ -597,7 +603,7 @@ function createClock(now, loopLimit) {

if (performancePresent) {
clock.performance = Object.create(global.performance);
clock.performance.now = function nowTime() {
clock.performance.now = function lolexNow() {
return clock.hrNow;
};
}
Expand Down Expand Up @@ -625,32 +631,25 @@ function createClock(now, loopLimit) {
}
exports.createClock = createClock;

exports.install = function install(target, now, toFake, loopLimit) {
var i, l;

if (target instanceof Date) {
toFake = now;
now = target.getTime();
target = null;
}

if (typeof target === "number") {
toFake = now;
now = target;
target = null;
}

if (!target) {
target = global;
}
/**
* @param config {Object} optional config
* @param config.target {Object} the target to install timers in (default `window`)
* @param config.now {number|Date} a number (in milliseconds) or a Date object (default epoch)
* @param config.toFake {string[]} names of the methods that should be faked.
* @param config.loopLimit {number} the maximum number of timers that will be run when calling runAll()
*/
exports.install = function install(config) {
config = typeof config !== "undefined" ? config : {};

var clock = createClock(now, loopLimit);
var i, l;
var target = config.target || global;
var clock = createClock(config.now, config.loopLimit);

clock.uninstall = function () {
uninstall(clock, target);
};

clock.methods = toFake || [];
clock.methods = config.toFake || [];

if (clock.methods.length === 0) {
clock.methods = keys(timers);
Expand Down

0 comments on commit 152f841

Please sign in to comment.