assertron 11.5.4 → 11.6.0
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
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
|
|
11
11
|
[![Visual Studio Code][vscode-image]][vscode-url]
|
|
12
12
|
|
|
13
|
-
A supplementary assertion library that runs on
|
|
13
|
+
A supplementary assertion library that runs on Node.js, Bun, Deno and the browser.
|
|
14
|
+
|
|
15
|
+
The shipped code imports no platform builtins, so the same `esm/` and `cjs/` output loads
|
|
16
|
+
everywhere. CI runs a smoke test against the build output on Node, Bun and Deno on every
|
|
17
|
+
pull request, so that claim is executed rather than asserted.
|
|
14
18
|
|
|
15
19
|
## Install
|
|
16
20
|
|
|
@@ -1,43 +1,16 @@
|
|
|
1
|
-
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
2
1
|
const require_defineProperty = require("../_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/defineProperty.js");
|
|
3
|
-
let perf_hooks = require("perf_hooks");
|
|
4
|
-
perf_hooks = require_runtime.__toESM(perf_hooks, 1);
|
|
5
2
|
//#region ts/assert-order/StateMachine.ts
|
|
6
|
-
|
|
7
|
-
let
|
|
8
|
-
|
|
9
|
-
let tick;
|
|
10
|
-
timeTracker = {
|
|
3
|
+
const timeTracker = (() => {
|
|
4
|
+
let tick = 0;
|
|
5
|
+
return {
|
|
11
6
|
start() {
|
|
12
|
-
tick =
|
|
7
|
+
tick = performance.now();
|
|
13
8
|
},
|
|
14
9
|
taken() {
|
|
15
|
-
|
|
16
|
-
return second * 1e3 + nanoSecond / 1e6;
|
|
10
|
+
return performance.now() - tick;
|
|
17
11
|
}
|
|
18
12
|
};
|
|
19
|
-
}
|
|
20
|
-
const now = perf_hooks.performance.now;
|
|
21
|
-
let tick;
|
|
22
|
-
timeTracker = {
|
|
23
|
-
start() {
|
|
24
|
-
tick = now();
|
|
25
|
-
},
|
|
26
|
-
taken() {
|
|
27
|
-
return now() - tick;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
} else {
|
|
31
|
-
let tick;
|
|
32
|
-
timeTracker = {
|
|
33
|
-
start() {
|
|
34
|
-
tick = Date.now();
|
|
35
|
-
},
|
|
36
|
-
taken() {
|
|
37
|
-
return Date.now() - tick;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
13
|
+
})();
|
|
41
14
|
var StateMachine = class {
|
|
42
15
|
constructor(maxStep) {
|
|
43
16
|
require_defineProperty.default(this, "listeners", {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateMachine.js","names":[
|
|
1
|
+
{"version":3,"file":"StateMachine.js","names":[],"sources":["../../ts/assert-order/StateMachine.ts"],"sourcesContent":["import type { State } from './types.js'\n\n// `performance.now()` is the one high-resolution clock every target runtime agrees on:\n// a global in Node (this package requires >= 20), Bun, Deno and the browser. There is no\n// fallback arm because there is no supported host that lacks it, and an arm no test can\n// reach is not a safety net.\nconst timeTracker = (() => {\n\tlet tick = 0\n\treturn {\n\t\tstart() {\n\t\t\ttick = performance.now()\n\t\t},\n\t\ttaken() {\n\t\t\treturn performance.now() - tick\n\t\t},\n\t}\n})()\n\nexport class StateMachine {\n\tlisteners: Record<number, Array<() => void>> = {}\n\tstep = 1\n\tmaxStep?: number\n\n\tsubStep = 0\n\tminSubStep?: number\n\tmaxSubStep?: number\n\tconstructor(maxStep?: number) {\n\t\tthis.maxStep = maxStep\n\t\ttimeTracker.start()\n\t}\n\tjump(step: number) {\n\t\tthis.step = step\n\t\tthis.subStep = 0\n\t\treturn this.step\n\t}\n\tmove() {\n\t\tconst listeners = this.listeners[this.step]\n\t\tthis.step = this.step + 1\n\t\tthis.subStep = 0\n\t\tif (listeners) {\n\t\t\tfor (const l of listeners) l()\n\t\t}\n\t\treturn this.step\n\t}\n\tmoveSubStep() {\n\t\tconst subStep = ++this.subStep\n\t\tif (this.maxSubStep === this.subStep) this.move()\n\t\treturn subStep\n\t}\n\tget(): State {\n\t\tconst { step, subStep, maxStep, minSubStep, maxSubStep } = this\n\t\treturn {\n\t\t\tstep,\n\t\t\tmaxStep,\n\t\t\tsubStep,\n\t\t\tminSubStep,\n\t\t\tmaxSubStep,\n\t\t}\n\t}\n\ton(step: number, listener: () => void) {\n\t\tthis.listeners[step] = [listener]\n\t}\n\tisNotValid(step: number) {\n\t\treturn step !== this.step || (this.maxStep !== undefined && this.maxStep < step)\n\t}\n\tisValid(step: number) {\n\t\treturn step === this.step\n\t}\n\tisMaxStepDefined() {\n\t\treturn this.maxStep !== undefined\n\t}\n\tstopAccepting() {\n\t\tthis.maxStep = this.step - 1\n\t}\n\tisAccepting() {\n\t\t// istanbul ignore next\n\t\treturn this.maxStep ? this.maxStep >= this.step : true\n\t}\n\tgetTimeTaken() {\n\t\treturn timeTracker.taken()\n\t}\n}\n"],"mappings":";;AAMA,MAAM,qBAAqB;CAC1B,IAAI,OAAO;CACX,OAAO;EACN,QAAQ;GACP,OAAO,YAAY,IAAI;EACxB;EACA,QAAQ;GACP,OAAO,YAAY,IAAI,IAAI;EAC5B;CACD;AACD,EAAA,CAAG;AAEH,IAAa,eAAb,MAA0B;CAQzB,YAAY,SAAkB;EAP9B,uBAAA,QAAA,MAAA,aAA+C,CAAC,CAAA;EAChD,uBAAA,QAAA,MAAA,QAAO,CAAA;EACP,uBAAA,QAAA,MAAA,WAAA,KAAA,CAAA;EAEA,uBAAA,QAAA,MAAA,WAAU,CAAA;EACV,uBAAA,QAAA,MAAA,cAAA,KAAA,CAAA;EACA,uBAAA,QAAA,MAAA,cAAA,KAAA,CAAA;EAEC,KAAK,UAAU;EACf,YAAY,MAAM;CACnB;CACA,KAAK,MAAc;EAClB,KAAK,OAAO;EACZ,KAAK,UAAU;EACf,OAAO,KAAK;CACb;CACA,OAAO;EACN,MAAM,YAAY,KAAK,UAAU,KAAK;EACtC,KAAK,OAAO,KAAK,OAAO;EACxB,KAAK,UAAU;EACf,IAAI,WACH,KAAK,MAAM,KAAK,WAAW,EAAE;EAE9B,OAAO,KAAK;CACb;CACA,cAAc;EACb,MAAM,UAAU,EAAE,KAAK;EACvB,IAAI,KAAK,eAAe,KAAK,SAAS,KAAK,KAAK;EAChD,OAAO;CACR;CACA,MAAa;EACZ,MAAM,EAAE,MAAM,SAAS,SAAS,YAAY,eAAe;EAC3D,OAAO;GACN;GACA;GACA;GACA;GACA;EACD;CACD;CACA,GAAG,MAAc,UAAsB;EACtC,KAAK,UAAU,QAAQ,CAAC,QAAQ;CACjC;CACA,WAAW,MAAc;EACxB,OAAO,SAAS,KAAK,QAAS,KAAK,YAAY,KAAA,KAAa,KAAK,UAAU;CAC5E;CACA,QAAQ,MAAc;EACrB,OAAO,SAAS,KAAK;CACtB;CACA,mBAAmB;EAClB,OAAO,KAAK,YAAY,KAAA;CACzB;CACA,gBAAgB;EACf,KAAK,UAAU,KAAK,OAAO;CAC5B;CACA,cAAc;;EAEb,OAAO,KAAK,UAAU,KAAK,WAAW,KAAK,OAAO;CACnD;CACA,eAAe;EACd,OAAO,YAAY,MAAM;CAC1B;AACD"}
|
|
@@ -1,40 +1,16 @@
|
|
|
1
1
|
import _defineProperty from "../_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/defineProperty.js";
|
|
2
|
-
import * as perf from "perf_hooks";
|
|
3
2
|
//#region ts/assert-order/StateMachine.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
timeTracker = {
|
|
3
|
+
const timeTracker = (() => {
|
|
4
|
+
let tick = 0;
|
|
5
|
+
return {
|
|
8
6
|
start() {
|
|
9
|
-
tick =
|
|
7
|
+
tick = performance.now();
|
|
10
8
|
},
|
|
11
9
|
taken() {
|
|
12
|
-
|
|
13
|
-
return second * 1e3 + nanoSecond / 1e6;
|
|
10
|
+
return performance.now() - tick;
|
|
14
11
|
}
|
|
15
12
|
};
|
|
16
|
-
}
|
|
17
|
-
const now = perf.performance.now;
|
|
18
|
-
let tick;
|
|
19
|
-
timeTracker = {
|
|
20
|
-
start() {
|
|
21
|
-
tick = now();
|
|
22
|
-
},
|
|
23
|
-
taken() {
|
|
24
|
-
return now() - tick;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
} else {
|
|
28
|
-
let tick;
|
|
29
|
-
timeTracker = {
|
|
30
|
-
start() {
|
|
31
|
-
tick = Date.now();
|
|
32
|
-
},
|
|
33
|
-
taken() {
|
|
34
|
-
return Date.now() - tick;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
}
|
|
13
|
+
})();
|
|
38
14
|
var StateMachine = class {
|
|
39
15
|
constructor(maxStep) {
|
|
40
16
|
_defineProperty(this, "listeners", {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateMachine.js","names":[],"sources":["../../ts/assert-order/StateMachine.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"StateMachine.js","names":[],"sources":["../../ts/assert-order/StateMachine.ts"],"sourcesContent":["import type { State } from './types.js'\n\n// `performance.now()` is the one high-resolution clock every target runtime agrees on:\n// a global in Node (this package requires >= 20), Bun, Deno and the browser. There is no\n// fallback arm because there is no supported host that lacks it, and an arm no test can\n// reach is not a safety net.\nconst timeTracker = (() => {\n\tlet tick = 0\n\treturn {\n\t\tstart() {\n\t\t\ttick = performance.now()\n\t\t},\n\t\ttaken() {\n\t\t\treturn performance.now() - tick\n\t\t},\n\t}\n})()\n\nexport class StateMachine {\n\tlisteners: Record<number, Array<() => void>> = {}\n\tstep = 1\n\tmaxStep?: number\n\n\tsubStep = 0\n\tminSubStep?: number\n\tmaxSubStep?: number\n\tconstructor(maxStep?: number) {\n\t\tthis.maxStep = maxStep\n\t\ttimeTracker.start()\n\t}\n\tjump(step: number) {\n\t\tthis.step = step\n\t\tthis.subStep = 0\n\t\treturn this.step\n\t}\n\tmove() {\n\t\tconst listeners = this.listeners[this.step]\n\t\tthis.step = this.step + 1\n\t\tthis.subStep = 0\n\t\tif (listeners) {\n\t\t\tfor (const l of listeners) l()\n\t\t}\n\t\treturn this.step\n\t}\n\tmoveSubStep() {\n\t\tconst subStep = ++this.subStep\n\t\tif (this.maxSubStep === this.subStep) this.move()\n\t\treturn subStep\n\t}\n\tget(): State {\n\t\tconst { step, subStep, maxStep, minSubStep, maxSubStep } = this\n\t\treturn {\n\t\t\tstep,\n\t\t\tmaxStep,\n\t\t\tsubStep,\n\t\t\tminSubStep,\n\t\t\tmaxSubStep,\n\t\t}\n\t}\n\ton(step: number, listener: () => void) {\n\t\tthis.listeners[step] = [listener]\n\t}\n\tisNotValid(step: number) {\n\t\treturn step !== this.step || (this.maxStep !== undefined && this.maxStep < step)\n\t}\n\tisValid(step: number) {\n\t\treturn step === this.step\n\t}\n\tisMaxStepDefined() {\n\t\treturn this.maxStep !== undefined\n\t}\n\tstopAccepting() {\n\t\tthis.maxStep = this.step - 1\n\t}\n\tisAccepting() {\n\t\t// istanbul ignore next\n\t\treturn this.maxStep ? this.maxStep >= this.step : true\n\t}\n\tgetTimeTaken() {\n\t\treturn timeTracker.taken()\n\t}\n}\n"],"mappings":";;AAMA,MAAM,qBAAqB;CAC1B,IAAI,OAAO;CACX,OAAO;EACN,QAAQ;GACP,OAAO,YAAY,IAAI;EACxB;EACA,QAAQ;GACP,OAAO,YAAY,IAAI,IAAI;EAC5B;CACD;AACD,EAAA,CAAG;AAEH,IAAa,eAAb,MAA0B;CAQzB,YAAY,SAAkB;EAP9B,gBAAA,MAAA,aAA+C,CAAC,CAAA;EAChD,gBAAA,MAAA,QAAO,CAAA;EACP,gBAAA,MAAA,WAAA,KAAA,CAAA;EAEA,gBAAA,MAAA,WAAU,CAAA;EACV,gBAAA,MAAA,cAAA,KAAA,CAAA;EACA,gBAAA,MAAA,cAAA,KAAA,CAAA;EAEC,KAAK,UAAU;EACf,YAAY,MAAM;CACnB;CACA,KAAK,MAAc;EAClB,KAAK,OAAO;EACZ,KAAK,UAAU;EACf,OAAO,KAAK;CACb;CACA,OAAO;EACN,MAAM,YAAY,KAAK,UAAU,KAAK;EACtC,KAAK,OAAO,KAAK,OAAO;EACxB,KAAK,UAAU;EACf,IAAI,WACH,KAAK,MAAM,KAAK,WAAW,EAAE;EAE9B,OAAO,KAAK;CACb;CACA,cAAc;EACb,MAAM,UAAU,EAAE,KAAK;EACvB,IAAI,KAAK,eAAe,KAAK,SAAS,KAAK,KAAK;EAChD,OAAO;CACR;CACA,MAAa;EACZ,MAAM,EAAE,MAAM,SAAS,SAAS,YAAY,eAAe;EAC3D,OAAO;GACN;GACA;GACA;GACA;GACA;EACD;CACD;CACA,GAAG,MAAc,UAAsB;EACtC,KAAK,UAAU,QAAQ,CAAC,QAAQ;CACjC;CACA,WAAW,MAAc;EACxB,OAAO,SAAS,KAAK,QAAS,KAAK,YAAY,KAAA,KAAa,KAAK,UAAU;CAC5E;CACA,QAAQ,MAAc;EACrB,OAAO,SAAS,KAAK;CACtB;CACA,mBAAmB;EAClB,OAAO,KAAK,YAAY,KAAA;CACzB;CACA,gBAAgB;EACf,KAAK,UAAU,KAAK,OAAO;CAC5B;CACA,cAAc;;EAEb,OAAO,KAAK,UAAU,KAAK,WAAW,KAAK,OAAO;CACnD;CACA,eAAe;EACd,OAAO,YAAY,MAAM;CAC1B;AACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "assertron",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.6.0",
|
|
4
4
|
"description": "A supplementary assertion library",
|
|
5
5
|
"homepage": "https://github.com/cyberuni/assertron",
|
|
6
6
|
"bugs": {
|
|
@@ -29,9 +29,6 @@
|
|
|
29
29
|
},
|
|
30
30
|
"main": "./cjs/index.js",
|
|
31
31
|
"module": "./esm/index.js",
|
|
32
|
-
"browser": {
|
|
33
|
-
"perf_hooks": false
|
|
34
|
-
},
|
|
35
32
|
"types": "./esm/index.d.ts",
|
|
36
33
|
"files": [
|
|
37
34
|
"cjs",
|
|
@@ -46,7 +43,7 @@
|
|
|
46
43
|
"path-equal": "^1.2.7",
|
|
47
44
|
"satisfier": "^5.4.4",
|
|
48
45
|
"tersify": "^4.0.6",
|
|
49
|
-
"type-plus": "^
|
|
46
|
+
"type-plus": "^8.0.0-beta.10"
|
|
50
47
|
},
|
|
51
48
|
"devDependencies": {
|
|
52
49
|
"@biomejs/biome": "^2.5.11",
|
|
@@ -85,10 +82,13 @@
|
|
|
85
82
|
"nuke": "pnpm clean && rimraf node_modules .turbo",
|
|
86
83
|
"release": "changeset publish",
|
|
87
84
|
"size": "size-limit",
|
|
85
|
+
"smoke": "node scripts/smoke.mjs && node scripts/smoke.cjs",
|
|
86
|
+
"smoke:bun": "bun run scripts/smoke.mjs && bun run scripts/smoke.cjs",
|
|
87
|
+
"smoke:deno": "deno run --allow-read scripts/smoke.mjs && deno run --allow-read scripts/smoke.cjs",
|
|
88
88
|
"test": "vitest run",
|
|
89
89
|
"test:watch": "vitest",
|
|
90
90
|
"typecheck": "tsc",
|
|
91
|
-
"verify": "biome ci . && turbo run build typecheck coverage knip size",
|
|
91
|
+
"verify": "biome ci . && turbo run build typecheck coverage knip size smoke",
|
|
92
92
|
"version": "changeset version"
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -1,45 +1,20 @@
|
|
|
1
|
-
// Deliberately the bare specifier, not `node:perf_hooks`: package.json's `browser`
|
|
2
|
-
// field maps `perf_hooks` to `false` for bundlers, and that mapping does not apply to
|
|
3
|
-
// the `node:` prefixed form.
|
|
4
|
-
// biome-ignore lint/style/useNodejsImportProtocol: see above
|
|
5
|
-
import * as perf from 'perf_hooks'
|
|
6
1
|
import type { State } from './types.js'
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
taken() {
|
|
17
|
-
const [second, nanoSecond] = globalThis.process.hrtime(tick)
|
|
18
|
-
return second * 1000 + nanoSecond / 1e6
|
|
19
|
-
},
|
|
20
|
-
}
|
|
21
|
-
} else if (perf.performance && typeof perf.performance.now === 'function') {
|
|
22
|
-
const now = perf.performance.now
|
|
23
|
-
let tick: number
|
|
24
|
-
timeTracker = {
|
|
3
|
+
// `performance.now()` is the one high-resolution clock every target runtime agrees on:
|
|
4
|
+
// a global in Node (this package requires >= 20), Bun, Deno and the browser. There is no
|
|
5
|
+
// fallback arm because there is no supported host that lacks it, and an arm no test can
|
|
6
|
+
// reach is not a safety net.
|
|
7
|
+
const timeTracker = (() => {
|
|
8
|
+
let tick = 0
|
|
9
|
+
return {
|
|
25
10
|
start() {
|
|
26
|
-
tick = now()
|
|
11
|
+
tick = performance.now()
|
|
27
12
|
},
|
|
28
13
|
taken() {
|
|
29
|
-
return now() - tick
|
|
14
|
+
return performance.now() - tick
|
|
30
15
|
},
|
|
31
16
|
}
|
|
32
|
-
}
|
|
33
|
-
let tick: number
|
|
34
|
-
timeTracker = {
|
|
35
|
-
start() {
|
|
36
|
-
tick = Date.now()
|
|
37
|
-
},
|
|
38
|
-
taken() {
|
|
39
|
-
return Date.now() - tick
|
|
40
|
-
},
|
|
41
|
-
}
|
|
42
|
-
}
|
|
17
|
+
})()
|
|
43
18
|
|
|
44
19
|
export class StateMachine {
|
|
45
20
|
listeners: Record<number, Array<() => void>> = {}
|