Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2023-07-13 09:09:17 +00:00
parent 4fad06f438
commit 40a500c743
4168 changed files with 298222 additions and 374905 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@sinonjs/commons",
"version": "2.0.0",
"version": "3.0.0",
"description": "Simple functions shared among the sinon end user libraries",
"main": "lib/index.js",
"types": "./types/index.d.ts",

View file

@ -255,6 +255,13 @@ Advances the clock to the the moment of the first scheduled timer, firing it.
The `nextAsync()` will also break the event loop, allowing any scheduled promise
callbacks to execute _before_ running the 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()`
Removes all timers and ticks without firing them, and sets `now` to `config.now`

View file

@ -1,7 +1,7 @@
{
"name": "@sinonjs/fake-timers",
"description": "Fake JavaScript timers",
"version": "10.0.2",
"version": "10.3.0",
"homepage": "https://github.com/sinonjs/fake-timers",
"author": "Christian Johansen",
"repository": {
@ -36,19 +36,19 @@
"src/"
],
"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"
},
"nyc": {
"branches": 85,

View file

@ -79,6 +79,7 @@ const globalObject = require("@sinonjs/commons").global;
* @property {function(): Promise<number>} runToLastAsync
* @property {function(): void} reset
* @property {function(number | Date): void} setSystemTime
* @property {function(number): void} jump
* @property {Performance} performance
* @property {function(number[]): number[]} hrtime - process.hrtime (legacy)
* @property {function(): void} uninstall Uninstall the clock.
@ -1605,6 +1606,25 @@ function withGlobal(_global) {
}
};
/**
* @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) {
clock.performance = Object.create(null);
clock.performance.now = fakePerformanceNow;