@sinonjs/fake-timers
Advanced tools
Comparing version 10.0.2 to 10.1.0
{ | ||
"name": "@sinonjs/fake-timers", | ||
"description": "Fake JavaScript timers", | ||
"version": "10.0.2", | ||
"version": "10.1.0", | ||
"homepage": "https://github.com/sinonjs/fake-timers", | ||
@@ -39,15 +39,15 @@ "author": "Christian Johansen", | ||
"devDependencies": { | ||
"@sinonjs/eslint-config": "4.0.6", | ||
"@sinonjs/referee-sinon": "10.1.0", | ||
"husky": "^8.0.0", | ||
"jsdom": "20.0.2", | ||
"lint-staged": "13.0.3", | ||
"mocha": "10.1.0", | ||
"@sinonjs/eslint-config": "^4.1.0", | ||
"@sinonjs/referee-sinon": "11.0.0", | ||
"husky": "^8.0.3", | ||
"jsdom": "22.0.0", | ||
"lint-staged": "13.2.2", | ||
"mocha": "10.2.0", | ||
"mochify": "9.2.0", | ||
"nyc": "15.1.0", | ||
"prettier": "2.7.1" | ||
"prettier": "2.8.8" | ||
}, | ||
"main": "./src/fake-timers-src.js", | ||
"dependencies": { | ||
"@sinonjs/commons": "^2.0.0" | ||
"@sinonjs/commons": "^3.0.0" | ||
}, | ||
@@ -54,0 +54,0 @@ "nyc": { |
@@ -258,2 +258,9 @@ # `@sinonjs/fake-timers` | ||
### `clock.jump(time)` | ||
Advance the clock by jumping forward in time, firing callbacks at most once. | ||
`time` takes the same formats as [`clock.tick`](#clockticktime--await-clocktickasynctime). | ||
This can be used to simulate the JS engine (such as a browser) being put to sleep and resumed later, skipping intermediary timers. | ||
### `clock.reset()` | ||
@@ -260,0 +267,0 @@ |
@@ -82,2 +82,3 @@ "use strict"; | ||
* @property {function(number | Date): void} setSystemTime | ||
* @property {function(number): void} jump | ||
* @property {Performance} performance | ||
@@ -1609,2 +1610,21 @@ * @property {function(number[]): number[]} hrtime - process.hrtime (legacy) | ||
/** | ||
* @param {string|number} tickValue number of milliseconds or a human-readable value like "01:11:15" | ||
* @returns {number} will return the new `now` value | ||
*/ | ||
clock.jump = function jump(tickValue) { | ||
const msFloat = | ||
typeof tickValue === "number" | ||
? tickValue | ||
: parseTime(tickValue); | ||
const ms = Math.floor(msFloat); | ||
for (const timer of Object.values(clock.timers)) { | ||
if (clock.now + ms > timer.callAt) { | ||
timer.callAt = clock.now + ms; | ||
} | ||
} | ||
clock.tick(ms); | ||
}; | ||
if (performancePresent) { | ||
@@ -1611,0 +1631,0 @@ clock.performance = Object.create(null); |
80098
1567
359
+ Added@sinonjs/commons@3.0.1(transitive)
- Removed@sinonjs/commons@2.0.0(transitive)
Updated@sinonjs/commons@^3.0.0