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 <[email protected]>
Carl-Erik Kopseng <[email protected]>
Christian Johansen <[email protected]>
Morgan Roderick <[email protected]>
Maximilian Antoni <[email protected]>
Mark Wubben <[email protected]>
Soutaro Matsumoto <[email protected]>
Duncan Beevers <[email protected]>
Soutaro Matsumoto <[email protected]>
Rogier Schouten <[email protected]>
Karl O'Keeffe <[email protected]>
Thibault Hild <[email protected]>
Clark Tomlinson <[email protected]>
Josh Goldberg <[email protected]>
Andy Edwards <[email protected]>
Benjamin Gruenbaum <[email protected]>
Curtis M. Humphrey, Ph.D <[email protected]>
Kyle Fleming <[email protected]>
Mark Banner <[email protected]>
Nando <[email protected]>
Simen Bekkhus <[email protected]>
Sylvain Fraïssé <[email protected]>
Andy Edwards <jedwards@fastmail.com>
Thibault Hild <[email protected].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.