chronokinesis 8.0.0 → 8.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,7 +28,7 @@ Mock time and date for traveling and freezing. Inspired and borrowed from [timek
28
28
  - [Caveats when mocking high-resolution clocks](#caveats-when-mocking-high-resolution-clocks)
29
29
  - [Acknowledgements](#acknowledgements)
30
30
 
31
- <!-- tocstop -->
31
+ <!-- /toc -->
32
32
 
33
33
  ## Introduction
34
34
 
@@ -12,7 +12,7 @@
12
12
  */
13
13
  const kNativeDate = Symbol.for('chronokinesis native date');
14
14
 
15
- const NativeDate = Date[kNativeDate] || Date;
15
+ const NativeDate = Date[kNativeDate] ?? Date;
16
16
  const nativeGetTimezoneOffset = NativeDate.prototype.getTimezoneOffset;
17
17
 
18
18
  /* c8 ignore start -- environment-capability guards; false branches only hit in browser (isomorphic test) */
@@ -25,8 +25,8 @@
25
25
  // Anchor native perf.now against native hrtime at module load so that later reads
26
26
  // can reconstruct real native perf.now even when process.hrtime has been swapped
27
27
  // (Node <22 wires performance.now to process.hrtime internally).
28
- const perfAnchorMs = nativePerformanceNow ? nativePerformanceNow.call(nativePerformance) : 0;
29
- const hrtimeAnchorNs = nativeHrtimeBigint ? nativeHrtimeBigint.call(nativeProcess) : 0n;
28
+ const perfAnchorMs = nativePerformanceNow?.call(nativePerformance) ?? 0;
29
+ const hrtimeAnchorNs = nativeHrtimeBigint?.call(nativeProcess) ?? 0n;
30
30
  /* c8 ignore stop */
31
31
 
32
32
  let freezedAt = null;
@@ -231,8 +231,7 @@
231
231
  }
232
232
 
233
233
  function fakeHrtimeNs() {
234
- if (freezedHrtimeNs !== null) return freezedHrtimeNs;
235
- return nativeHrtimeBigint.call(nativeProcess) + hrtimeOffset;
234
+ return freezedHrtimeNs ?? nativeHrtimeBigint.call(nativeProcess) + hrtimeOffset;
236
235
  }
237
236
 
238
237
  function fakeHrtime(prev) {
@@ -254,8 +253,7 @@
254
253
  };
255
254
 
256
255
  function fakePerformanceNow() {
257
- if (freezedPerformanceNow !== null) return freezedPerformanceNow;
258
- return nativePerformanceNowFromHrtime() + performanceNowOffset;
256
+ return freezedPerformanceNow ?? nativePerformanceNowFromHrtime() + performanceNowOffset;
259
257
  }
260
258
 
261
259
  function instantiate(type, args) {
package/dist/index.cjs CHANGED
@@ -8,7 +8,7 @@
8
8
  */
9
9
  const kNativeDate = Symbol.for('chronokinesis native date');
10
10
 
11
- const NativeDate = Date[kNativeDate] || Date;
11
+ const NativeDate = Date[kNativeDate] ?? Date;
12
12
  const nativeGetTimezoneOffset = NativeDate.prototype.getTimezoneOffset;
13
13
 
14
14
  /* c8 ignore start -- environment-capability guards; false branches only hit in browser (isomorphic test) */
@@ -21,8 +21,8 @@ const nativePerformanceNow = nativePerformance && typeof nativePerformance.now =
21
21
  // Anchor native perf.now against native hrtime at module load so that later reads
22
22
  // can reconstruct real native perf.now even when process.hrtime has been swapped
23
23
  // (Node <22 wires performance.now to process.hrtime internally).
24
- const perfAnchorMs = nativePerformanceNow ? nativePerformanceNow.call(nativePerformance) : 0;
25
- const hrtimeAnchorNs = nativeHrtimeBigint ? nativeHrtimeBigint.call(nativeProcess) : 0n;
24
+ const perfAnchorMs = nativePerformanceNow?.call(nativePerformance) ?? 0;
25
+ const hrtimeAnchorNs = nativeHrtimeBigint?.call(nativeProcess) ?? 0n;
26
26
  /* c8 ignore stop */
27
27
 
28
28
  let freezedAt = null;
@@ -227,8 +227,7 @@ function shiftAndLockFakeClocks(deltaMs) {
227
227
  }
228
228
 
229
229
  function fakeHrtimeNs() {
230
- if (freezedHrtimeNs !== null) return freezedHrtimeNs;
231
- return nativeHrtimeBigint.call(nativeProcess) + hrtimeOffset;
230
+ return freezedHrtimeNs ?? nativeHrtimeBigint.call(nativeProcess) + hrtimeOffset;
232
231
  }
233
232
 
234
233
  function fakeHrtime(prev) {
@@ -250,8 +249,7 @@ fakeHrtime.bigint = function fakeHrtimeBigint() {
250
249
  };
251
250
 
252
251
  function fakePerformanceNow() {
253
- if (freezedPerformanceNow !== null) return freezedPerformanceNow;
254
- return nativePerformanceNowFromHrtime() + performanceNowOffset;
252
+ return freezedPerformanceNow ?? nativePerformanceNowFromHrtime() + performanceNowOffset;
255
253
  }
256
254
 
257
255
  function instantiate(type, args) {
package/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  */
7
7
  const kNativeDate = Symbol.for('chronokinesis native date');
8
8
 
9
- const NativeDate = Date[kNativeDate] || Date;
9
+ const NativeDate = Date[kNativeDate] ?? Date;
10
10
  const nativeGetTimezoneOffset = NativeDate.prototype.getTimezoneOffset;
11
11
 
12
12
  /* c8 ignore start -- environment-capability guards; false branches only hit in browser (isomorphic test) */
@@ -19,8 +19,8 @@ const nativePerformanceNow = nativePerformance && typeof nativePerformance.now =
19
19
  // Anchor native perf.now against native hrtime at module load so that later reads
20
20
  // can reconstruct real native perf.now even when process.hrtime has been swapped
21
21
  // (Node <22 wires performance.now to process.hrtime internally).
22
- const perfAnchorMs = nativePerformanceNow ? nativePerformanceNow.call(nativePerformance) : 0;
23
- const hrtimeAnchorNs = nativeHrtimeBigint ? nativeHrtimeBigint.call(nativeProcess) : 0n;
22
+ const perfAnchorMs = nativePerformanceNow?.call(nativePerformance) ?? 0;
23
+ const hrtimeAnchorNs = nativeHrtimeBigint?.call(nativeProcess) ?? 0n;
24
24
  /* c8 ignore stop */
25
25
 
26
26
  let freezedAt = null;
@@ -225,8 +225,7 @@ function shiftAndLockFakeClocks(deltaMs) {
225
225
  }
226
226
 
227
227
  function fakeHrtimeNs() {
228
- if (freezedHrtimeNs !== null) return freezedHrtimeNs;
229
- return nativeHrtimeBigint.call(nativeProcess) + hrtimeOffset;
228
+ return freezedHrtimeNs ?? nativeHrtimeBigint.call(nativeProcess) + hrtimeOffset;
230
229
  }
231
230
 
232
231
  function fakeHrtime(prev) {
@@ -248,8 +247,7 @@ fakeHrtime.bigint = function fakeHrtimeBigint() {
248
247
  };
249
248
 
250
249
  function fakePerformanceNow() {
251
- if (freezedPerformanceNow !== null) return freezedPerformanceNow;
252
- return nativePerformanceNowFromHrtime() + performanceNowOffset;
250
+ return freezedPerformanceNow ?? nativePerformanceNowFromHrtime() + performanceNowOffset;
253
251
  }
254
252
 
255
253
  function instantiate(type, args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chronokinesis",
3
- "version": "8.0.0",
3
+ "version": "8.0.1",
4
4
  "description": "Module for testing time-dependent code",
5
5
  "author": {
6
6
  "name": "Pål Edman",
@@ -23,7 +23,7 @@
23
23
  "types": "./index.d.ts"
24
24
  },
25
25
  "scripts": {
26
- "toc": "node generate-api-toc.cjs",
26
+ "toc": "toc README.md",
27
27
  "test": "mocha",
28
28
  "lint": "eslint . --cache && prettier . --check --cache",
29
29
  "test:lcov": "c8 -r lcov -r text mocha && npm run lint",
@@ -56,18 +56,20 @@
56
56
  "fake now"
57
57
  ],
58
58
  "devDependencies": {
59
+ "@0dep/toc": "^1.0.1",
60
+ "@eslint/js": "^10.0.1",
59
61
  "@rollup/plugin-commonjs": "^29.0.0",
60
- "c8": "^10.1.2",
62
+ "c8": "^12.0.0",
61
63
  "chai": "^6.2.0",
62
- "eslint": "^9.3.0",
63
- "happy-dom": "^17.6.1",
64
+ "eslint": "^10.10.0",
65
+ "globals": "^17.12.0",
66
+ "happy-dom": "^20.14.5",
64
67
  "lodash.clonedeep": "^4.5.0",
65
68
  "luxon": "^3.7.1",
66
- "markdown-toc": "^1.2.0",
67
- "mocha": "^11.0.1",
69
+ "mocha": "^12.0.1",
68
70
  "moment": "^2.30.1",
69
71
  "prettier": "^3.2.5",
70
72
  "rollup": "^4.12.1",
71
- "texample": "^0.1.0"
73
+ "texample": "^1.0.2"
72
74
  }
73
75
  }