@sinonjs/fake-timers
Advanced tools
Comparing version 10.1.0 to 10.2.0
{ | ||
"name": "@sinonjs/fake-timers", | ||
"description": "Fake JavaScript timers", | ||
"version": "10.1.0", | ||
"version": "10.2.0", | ||
"homepage": "https://github.com/sinonjs/fake-timers", | ||
@@ -6,0 +6,0 @@ "author": "Christian Johansen", |
@@ -70,2 +70,3 @@ # `@sinonjs/fake-timers` | ||
later to restore things as they were again. | ||
Note that in NodeJS also the [timers](https://nodejs.org/api/timers.html) module will receive fake timers when using global scope. | ||
@@ -150,3 +151,5 @@ ```js | ||
Installs FakeTimers using the specified config (otherwise with epoch `0` on the global scope). The following configuration options are available | ||
Installs FakeTimers using the specified config (otherwise with epoch `0` on the global scope). | ||
Note that in NodeJS also the [timers](https://nodejs.org/api/timers.html) module will receive fake timers when using global scope. | ||
The following configuration options are available | ||
@@ -153,0 +156,0 @@ | Parameter | Type | Default | Description | |
"use strict"; | ||
const globalObject = require("@sinonjs/commons").global; | ||
let timersModule; | ||
if (typeof require === "function" && typeof module === "object") { | ||
try { | ||
timersModule = require("timers"); | ||
} catch (e) { | ||
// ignored | ||
} | ||
} | ||
@@ -88,2 +96,3 @@ /** | ||
* @property {boolean} [shouldClearNativeTimers] inherited from config | ||
* @property {{methodName:string, original:any}[] | undefined} timersModuleMethods | ||
*/ | ||
@@ -890,2 +899,8 @@ /* eslint-enable jsdoc/require-property-description */ | ||
} | ||
if (clock.timersModuleMethods !== undefined) { | ||
for (let j = 0; j < clock.timersModuleMethods.length; j++) { | ||
const entry = clock.timersModuleMethods[j]; | ||
timersModule[entry.methodName] = entry.original; | ||
} | ||
} | ||
} | ||
@@ -1738,3 +1753,5 @@ | ||
} | ||
if (_global === globalObject && timersModule) { | ||
clock.timersModuleMethods = []; | ||
} | ||
for (i = 0, l = clock.methods.length; i < l; i++) { | ||
@@ -1759,2 +1776,14 @@ const nameOfMethodToReplace = clock.methods[i]; | ||
} | ||
if ( | ||
clock.timersModuleMethods !== undefined && | ||
timersModule[nameOfMethodToReplace] | ||
) { | ||
const original = timersModule[nameOfMethodToReplace]; | ||
clock.timersModuleMethods.push({ | ||
methodName: nameOfMethodToReplace, | ||
original: original, | ||
}); | ||
timersModule[nameOfMethodToReplace] = | ||
_global[nameOfMethodToReplace]; | ||
} | ||
} | ||
@@ -1761,0 +1790,0 @@ |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
81533
1597
362
1