Comparing version 2.1.1 to 2.1.2
v2.1.2 / 2017-07-25 | ||
================== | ||
* - does not fake process.nextTick by default - added .idea folder to .gitignore - fixed documentation - added clock teardowns in tests | ||
* overflowing the timer correctly (issue #67) | ||
v2.1.1 / 2017-07-19 | ||
@@ -3,0 +9,0 @@ ================== |
12
lolex.js
@@ -7,2 +7,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.lolex = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
var isRunningInIE = userAgent && userAgent.indexOf("MSIE ") > -1; | ||
var maxTimeout = Math.pow(2, 31) - 1; //see https://heycam.github.io/webidl/#abstract-opdef-converttoint | ||
@@ -196,2 +197,10 @@ // Make properties writable in IE, as per | ||
if (timer.hasOwnProperty("delay")) { | ||
timer.delay = timer.delay > maxTimeout ? 1 : timer.delay; | ||
} | ||
if (timer.hasOwnProperty("interval")) { | ||
timer.interval = timer.interval > maxTimeout ? 1 : timer.interval; | ||
} | ||
if (!clock.timers) { | ||
@@ -696,3 +705,4 @@ clock.timers = {}; | ||
if (clock.methods.length === 0) { | ||
clock.methods = keys(timers); | ||
// do not fake nextTick by default - GitHub#126 | ||
clock.methods = keys(timers).filter(function (key) {return key !== "nextTick";}); | ||
} | ||
@@ -699,0 +709,0 @@ |
{ | ||
"name": "lolex", | ||
"description": "Fake JavaScript timers", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"homepage": "http://github.com/sinonjs/lolex", | ||
@@ -6,0 +6,0 @@ "author": "Christian Johansen", |
@@ -8,2 +8,4 @@ # Lolex [![Build Status](https://secure.travis-ci.org/sinonjs/lolex.png)](http://travis-ci.org/sinonjs/lolex) [![bitHound Overall Score](https://www.bithound.io/github/sinonjs/lolex/badges/score.svg)](https://www.bithound.io/github/sinonjs/lolex) | ||
In addition in browser environment lolex provides a `performance` implementation that gets its time from the clock. In Node environments lolex provides a `nextTick` implementation that is synchronized with the clock - and a `process.hrtime` shim that works with the clock. | ||
Lolex can be used to simulate passing time in automated tests and other | ||
@@ -144,3 +146,3 @@ situations where you want the scheduling semantics, but don't want to actually | ||
`config.now` | Number/Date | 0 | installs lolex with the specified unix epoch | ||
`config.toFake` | String[] | [] | an array with explicit function names to hijack. You can pick from `setTimeout`, `clearTimeout`, `setImmediate`, `clearImmediate`,`setInterval`, `clearInterval`, and `Date`. E.g. `lolex.install({ toFake: ["setTimeout","clearTimeout"]})` | ||
`config.toFake` | String[] | ["setTimeout", "clearTimeout", "setImmediate", "clearImmediate","setInterval", "clearInterval", "Date"] | an array with explicit function names to hijack. *When not set, lolex will automatically fake all methods **except** `nextTick`* e.g., `lolex.install({ toFake: ["setTimeout","nextTick"]})` will fake only `setTimeout` and `nextTick` | ||
`config.loopLimit` | Number | 1000 | the maximum number of timers that will be run when calling runAll() | ||
@@ -197,4 +199,8 @@ `config.shouldAdvanceTime` | Boolean | false | tells lolex to increment mocked time automatically based on the real system time shift (e.g. the mocked time will be incremented by 20ms for every 20ms change in the real system time) | ||
### `clock.hrtime(prevTime?)` | ||
Only available in Node.JS, mimicks process.hrtime(). | ||
Only available in Node.js, mimicks process.hrtime(). | ||
### `clock.nextTick(callback)` | ||
Only available in Node.js, mimics `process.nextTick` to enable completely synchronous testing flows. | ||
### `clock.performance.now()` | ||
@@ -201,0 +207,0 @@ Only available in browser environments, mimicks performance.now(). |
@@ -5,2 +5,3 @@ "use strict"; | ||
var isRunningInIE = userAgent && userAgent.indexOf("MSIE ") > -1; | ||
var maxTimeout = Math.pow(2, 31) - 1; //see https://heycam.github.io/webidl/#abstract-opdef-converttoint | ||
@@ -194,2 +195,10 @@ // Make properties writable in IE, as per | ||
if (timer.hasOwnProperty("delay")) { | ||
timer.delay = timer.delay > maxTimeout ? 1 : timer.delay; | ||
} | ||
if (timer.hasOwnProperty("interval")) { | ||
timer.interval = timer.interval > maxTimeout ? 1 : timer.interval; | ||
} | ||
if (!clock.timers) { | ||
@@ -694,3 +703,4 @@ clock.timers = {}; | ||
if (clock.methods.length === 0) { | ||
clock.methods = keys(timers); | ||
// do not fake nextTick by default - GitHub#126 | ||
clock.methods = keys(timers).filter(function (key) {return key !== "nextTick";}); | ||
} | ||
@@ -697,0 +707,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
133263
2910
290