assertron 11.5.2 → 11.5.4
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 +7 -7
- package/cjs/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/defineProperty.js +12 -0
- package/cjs/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/toPrimitive.js +14 -0
- package/cjs/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/toPropertyKey.js +9 -0
- package/cjs/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/typeof.js +16 -0
- package/cjs/_virtual/_rolldown/runtime.js +23 -0
- package/cjs/assert-order/AssertOrder.d.ts +42 -39
- package/cjs/assert-order/AssertOrder.d.ts.map +1 -1
- package/cjs/assert-order/AssertOrder.js +118 -146
- package/cjs/assert-order/AssertOrder.js.map +1 -1
- package/cjs/assert-order/InvalidOrder.d.ts +10 -7
- package/cjs/assert-order/InvalidOrder.d.ts.map +1 -1
- package/cjs/assert-order/InvalidOrder.js +24 -43
- package/cjs/assert-order/InvalidOrder.js.map +1 -1
- package/cjs/assert-order/StateMachine.js +101 -156
- package/cjs/assert-order/StateMachine.js.map +1 -1
- package/cjs/assert-order/index.d.ts +4 -4
- package/cjs/assert-order/types.d.ts +9 -6
- package/cjs/assert-order/types.d.ts.map +1 -1
- package/cjs/assertron/assertron.d.ts +23 -20
- package/cjs/assertron/assertron.d.ts.map +1 -1
- package/cjs/assertron/assertron.js +36 -39
- package/cjs/assertron/assertron.js.map +1 -1
- package/cjs/assertron/falsy.js +5 -6
- package/cjs/assertron/falsy.js.map +1 -1
- package/cjs/assertron/index.d.ts +3 -3
- package/cjs/assertron/isInstanceof.js +6 -7
- package/cjs/assertron/isInstanceof.js.map +1 -1
- package/cjs/assertron/pathEqual.js +7 -8
- package/cjs/assertron/pathEqual.js.map +1 -1
- package/cjs/assertron/rejects.js +8 -8
- package/cjs/assertron/rejects.js.map +1 -1
- package/cjs/assertron/repeat.js +23 -31
- package/cjs/assertron/repeat.js.map +1 -1
- package/cjs/assertron/resolves.js +8 -8
- package/cjs/assertron/resolves.js.map +1 -1
- package/cjs/assertron/satisfies.d.ts +5 -10
- package/cjs/assertron/satisfies.d.ts.map +1 -1
- package/cjs/assertron/satisfies.js +12 -14
- package/cjs/assertron/satisfies.js.map +1 -1
- package/cjs/assertron/throws.js +48 -55
- package/cjs/assertron/throws.js.map +1 -1
- package/cjs/assertron/truthy.js +5 -6
- package/cjs/assertron/truthy.js.map +1 -1
- package/cjs/errors.d.ts +13 -10
- package/cjs/errors.d.ts.map +1 -1
- package/cjs/errors.js +19 -29
- package/cjs/errors.js.map +1 -1
- package/cjs/index.d.ts +10 -8
- package/cjs/index.js +98 -37
- package/cjs/index.js.map +1 -1
- package/cjs/package.json +3 -1
- package/cjs/types.d.ts +5 -2
- package/cjs/types.d.ts.map +1 -1
- package/cjs/utils/index.js +18 -25
- package/cjs/utils/index.js.map +1 -1
- package/cjs/utils/isErrorConstructor.js +4 -4
- package/cjs/utils/isErrorConstructor.js.map +1 -1
- package/cjs/utils/notEqualMessage.js +4 -4
- package/cjs/utils/notEqualMessage.js.map +1 -1
- package/cjs/utils/notSatisfiedMessage.js +14 -23
- package/cjs/utils/notSatisfiedMessage.js.map +1 -1
- package/cjs/utils/notThrownMessage.js +5 -5
- package/cjs/utils/notThrownMessage.js.map +1 -1
- package/cjs/utils/promiseMessages.js +7 -13
- package/cjs/utils/promiseMessages.js.map +1 -1
- package/cjs/utils/unexpectedErrorMessage.js +6 -6
- package/cjs/utils/unexpectedErrorMessage.js.map +1 -1
- package/esm/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/defineProperty.js +12 -0
- package/esm/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/toPrimitive.js +14 -0
- package/esm/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/toPropertyKey.js +9 -0
- package/esm/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/typeof.js +11 -0
- package/esm/assert-order/AssertOrder.d.ts +42 -39
- package/esm/assert-order/AssertOrder.d.ts.map +1 -1
- package/esm/assert-order/AssertOrder.js +119 -143
- package/esm/assert-order/AssertOrder.js.map +1 -1
- package/esm/assert-order/InvalidOrder.d.ts +10 -7
- package/esm/assert-order/InvalidOrder.d.ts.map +1 -1
- package/esm/assert-order/InvalidOrder.js +24 -39
- package/esm/assert-order/InvalidOrder.js.map +1 -1
- package/esm/assert-order/StateMachine.js +99 -129
- package/esm/assert-order/StateMachine.js.map +1 -1
- package/esm/assert-order/index.d.ts +4 -4
- package/esm/assert-order/types.d.ts +9 -6
- package/esm/assert-order/types.d.ts.map +1 -1
- package/esm/assertron/assertron.d.ts +23 -20
- package/esm/assertron/assertron.d.ts.map +1 -1
- package/esm/assertron/assertron.js +36 -36
- package/esm/assertron/assertron.js.map +1 -1
- package/esm/assertron/falsy.js +7 -4
- package/esm/assertron/falsy.js.map +1 -1
- package/esm/assertron/index.d.ts +3 -3
- package/esm/assertron/isInstanceof.js +8 -5
- package/esm/assertron/isInstanceof.js.map +1 -1
- package/esm/assertron/pathEqual.js +9 -6
- package/esm/assertron/pathEqual.js.map +1 -1
- package/esm/assertron/rejects.js +10 -6
- package/esm/assertron/rejects.js.map +1 -1
- package/esm/assertron/repeat.js +22 -25
- package/esm/assertron/repeat.js.map +1 -1
- package/esm/assertron/resolves.js +10 -6
- package/esm/assertron/resolves.js.map +1 -1
- package/esm/assertron/satisfies.d.ts +5 -10
- package/esm/assertron/satisfies.d.ts.map +1 -1
- package/esm/assertron/satisfies.js +14 -12
- package/esm/assertron/satisfies.js.map +1 -1
- package/esm/assertron/throws.js +47 -49
- package/esm/assertron/throws.js.map +1 -1
- package/esm/assertron/truthy.js +7 -4
- package/esm/assertron/truthy.js.map +1 -1
- package/esm/errors.d.ts +13 -10
- package/esm/errors.d.ts.map +1 -1
- package/esm/errors.js +20 -26
- package/esm/errors.js.map +1 -1
- package/esm/index.d.ts +10 -8
- package/esm/index.js +10 -7
- package/esm/index.js.map +1 -1
- package/esm/types.d.ts +5 -2
- package/esm/types.d.ts.map +1 -1
- package/esm/utils/index.js +13 -9
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/isErrorConstructor.js +6 -2
- package/esm/utils/isErrorConstructor.js.map +1 -1
- package/esm/utils/notEqualMessage.js +6 -2
- package/esm/utils/notEqualMessage.js.map +1 -1
- package/esm/utils/notSatisfiedMessage.js +15 -20
- package/esm/utils/notSatisfiedMessage.js.map +1 -1
- package/esm/utils/notThrownMessage.js +7 -3
- package/esm/utils/notThrownMessage.js.map +1 -1
- package/esm/utils/promiseMessages.js +9 -11
- package/esm/utils/promiseMessages.js.map +1 -1
- package/esm/utils/unexpectedErrorMessage.js +8 -4
- package/esm/utils/unexpectedErrorMessage.js.map +1 -1
- package/package.json +43 -68
- package/ts/assert-order/AssertOrder.ts +8 -6
- package/ts/assert-order/InvalidOrder.ts +4 -6
- package/ts/assert-order/StateMachine.ts +11 -7
- package/ts/assertron/assertron.ts +9 -19
- package/ts/assertron/falsy.ts +1 -2
- package/ts/assertron/isInstanceof.ts +1 -4
- package/ts/assertron/pathEqual.ts +1 -2
- package/ts/assertron/rejects.ts +2 -2
- package/ts/assertron/repeat.ts +5 -6
- package/ts/assertron/resolves.ts +3 -3
- package/ts/assertron/satisfies.ts +2 -4
- package/ts/assertron/throws.ts +14 -20
- package/ts/assertron/truthy.ts +1 -2
- package/ts/errors.ts +5 -1
- package/ts/index.ts +2 -2
- package/ts/utils/index.ts +1 -1
- package/ts/utils/notSatisfiedMessage.ts +2 -2
- package/ts/utils/promiseMessages.ts +5 -5
- package/cjs/assert-order/StateMachine.d.ts +0 -22
- package/cjs/assert-order/StateMachine.d.ts.map +0 -1
- package/cjs/assert-order/index.d.ts.map +0 -1
- package/cjs/assert-order/index.js +0 -20
- package/cjs/assert-order/index.js.map +0 -1
- package/cjs/assert-order/types.js +0 -3
- package/cjs/assert-order/types.js.map +0 -1
- package/cjs/assertron/falsy.d.ts +0 -2
- package/cjs/assertron/falsy.d.ts.map +0 -1
- package/cjs/assertron/index.d.ts.map +0 -1
- package/cjs/assertron/index.js +0 -18
- package/cjs/assertron/index.js.map +0 -1
- package/cjs/assertron/isInstanceof.d.ts +0 -3
- package/cjs/assertron/isInstanceof.d.ts.map +0 -1
- package/cjs/assertron/pathEqual.d.ts +0 -2
- package/cjs/assertron/pathEqual.d.ts.map +0 -1
- package/cjs/assertron/rejects.d.ts +0 -2
- package/cjs/assertron/rejects.d.ts.map +0 -1
- package/cjs/assertron/repeat.d.ts +0 -6
- package/cjs/assertron/repeat.d.ts.map +0 -1
- package/cjs/assertron/resolves.d.ts +0 -2
- package/cjs/assertron/resolves.d.ts.map +0 -1
- package/cjs/assertron/throws.d.ts +0 -6
- package/cjs/assertron/throws.d.ts.map +0 -1
- package/cjs/assertron/truthy.d.ts +0 -2
- package/cjs/assertron/truthy.d.ts.map +0 -1
- package/cjs/index.d.ts.map +0 -1
- package/cjs/types.js +0 -3
- package/cjs/types.js.map +0 -1
- package/cjs/utils/index.d.ts +0 -8
- package/cjs/utils/index.d.ts.map +0 -1
- package/cjs/utils/isErrorConstructor.d.ts +0 -3
- package/cjs/utils/isErrorConstructor.d.ts.map +0 -1
- package/cjs/utils/notEqualMessage.d.ts +0 -2
- package/cjs/utils/notEqualMessage.d.ts.map +0 -1
- package/cjs/utils/notSatisfiedMessage.d.ts +0 -3
- package/cjs/utils/notSatisfiedMessage.d.ts.map +0 -1
- package/cjs/utils/notThrownMessage.d.ts +0 -2
- package/cjs/utils/notThrownMessage.d.ts.map +0 -1
- package/cjs/utils/promiseMessages.d.ts +0 -3
- package/cjs/utils/promiseMessages.d.ts.map +0 -1
- package/cjs/utils/unexpectedErrorMessage.d.ts +0 -3
- package/cjs/utils/unexpectedErrorMessage.d.ts.map +0 -1
- package/esm/assert-order/StateMachine.d.ts +0 -22
- package/esm/assert-order/StateMachine.d.ts.map +0 -1
- package/esm/assert-order/index.d.ts.map +0 -1
- package/esm/assert-order/index.js +0 -4
- package/esm/assert-order/index.js.map +0 -1
- package/esm/assert-order/types.js +0 -2
- package/esm/assert-order/types.js.map +0 -1
- package/esm/assertron/falsy.d.ts +0 -2
- package/esm/assertron/falsy.d.ts.map +0 -1
- package/esm/assertron/index.d.ts.map +0 -1
- package/esm/assertron/index.js +0 -2
- package/esm/assertron/index.js.map +0 -1
- package/esm/assertron/isInstanceof.d.ts +0 -3
- package/esm/assertron/isInstanceof.d.ts.map +0 -1
- package/esm/assertron/pathEqual.d.ts +0 -2
- package/esm/assertron/pathEqual.d.ts.map +0 -1
- package/esm/assertron/rejects.d.ts +0 -2
- package/esm/assertron/rejects.d.ts.map +0 -1
- package/esm/assertron/repeat.d.ts +0 -6
- package/esm/assertron/repeat.d.ts.map +0 -1
- package/esm/assertron/resolves.d.ts +0 -2
- package/esm/assertron/resolves.d.ts.map +0 -1
- package/esm/assertron/throws.d.ts +0 -6
- package/esm/assertron/throws.d.ts.map +0 -1
- package/esm/assertron/truthy.d.ts +0 -2
- package/esm/assertron/truthy.d.ts.map +0 -1
- package/esm/index.d.ts.map +0 -1
- package/esm/types.js +0 -2
- package/esm/types.js.map +0 -1
- package/esm/utils/index.d.ts +0 -8
- package/esm/utils/index.d.ts.map +0 -1
- package/esm/utils/isErrorConstructor.d.ts +0 -3
- package/esm/utils/isErrorConstructor.d.ts.map +0 -1
- package/esm/utils/notEqualMessage.d.ts +0 -2
- package/esm/utils/notEqualMessage.d.ts.map +0 -1
- package/esm/utils/notSatisfiedMessage.d.ts +0 -3
- package/esm/utils/notSatisfiedMessage.d.ts.map +0 -1
- package/esm/utils/notThrownMessage.d.ts +0 -2
- package/esm/utils/notThrownMessage.d.ts.map +0 -1
- package/esm/utils/promiseMessages.d.ts +0 -3
- package/esm/utils/promiseMessages.d.ts.map +0 -1
- package/esm/utils/unexpectedErrorMessage.d.ts +0 -3
- package/esm/utils/unexpectedErrorMessage.d.ts.map +0 -1
- package/ts/assert-order/internalInterfaces.ts +0 -5
- package/ts/testUtils.ts +0 -81
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvalidOrder.js","
|
|
1
|
+
{"version":3,"file":"InvalidOrder.js","names":["AssertionError"],"sources":["../../ts/assert-order/InvalidOrder.ts"],"sourcesContent":["import { AssertionError } from '../errors.js'\nimport type { State } from './types.js'\n\nexport class InvalidOrder extends AssertionError {\n\tconstructor(\n\t\tpublic state: State,\n\t\tpublic method: string,\n\t\tpublic args: any[],\n\t\toptions: AssertionError.Options,\n\t) {\n\t\tsuper(method === 'end' ? getEndMessage(state) : getExpectingMessage(state, method, args), options)\n\t}\n}\n\nfunction getEndMessage(state: State) {\n\treturn `Planned for ${state.maxStep} step but expecting step ${state.step} when 'end()' is called`\n}\n\nfunction getExpectingMessage(state: State, method: string, args: any[]) {\n\treturn `Expecting ${getExpectingCalls(state)}, but received '${method}(${getMethodArgs(args)})'`\n}\n\nfunction getExpectingCalls(state: State) {\n\tlet message: string\n\tif (state.subStep === 0) {\n\t\tconst methods = ['is', 'once', 'any']\n\t\tmessage = methods.map((m) => `'${m}(${['any'].indexOf(m) === -1 ? state.step : `[${state.step}]`})'`).join(', ')\n\t} else {\n\t\tconst methods = ['exactly']\n\t\tmessage = methods.map((m) => `'${m}(${state.step}, ${state.maxSubStep})'`).join(', ')\n\t}\n\treturn message\n}\n\nfunction getMethodArgs(args: any[]) {\n\treturn args.map((a) => (Array.isArray(a) ? `[${a.join(', ')}]` : a)).join(', ')\n}\n"],"mappings":";;AAGA,IAAa,eAAb,cAAkCA,eAAAA,eAAe;CAChD,YACC,OACA,QACA,MACA,SACC;EACD,MAAM,WAAW,QAAQ,cAAc,KAAK,IAAI,oBAAoB,OAAO,QAAQ,IAAI,GAAG,OAAO;EAL1F,KAAA,QAAA;EACA,KAAA,SAAA;EACA,KAAA,OAAA;CAIR;AACD;AAEA,SAAS,cAAc,OAAc;CACpC,OAAO,eAAe,MAAM,QAAQ,2BAA2B,MAAM,KAAK;AAC3E;AAEA,SAAS,oBAAoB,OAAc,QAAgB,MAAa;CACvE,OAAO,aAAa,kBAAkB,KAAK,EAAE,kBAAkB,OAAO,GAAG,cAAc,IAAI,EAAE;AAC9F;AAEA,SAAS,kBAAkB,OAAc;CACxC,IAAI;CACJ,IAAI,MAAM,YAAY,GAErB,UAAU;EADO;EAAM;EAAQ;CACf,CAAC,CAAC,KAAK,MAAM,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,KAAK,MAAM,OAAO,IAAI,MAAM,KAAK,GAAG,GAAG,CAAC,CAAC,KAAK,IAAI;MAG/G,UAAU,CADO,SACD,CAAC,CAAC,KAAK,MAAM,IAAI,EAAE,GAAG,MAAM,KAAK,IAAI,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,IAAI;CAErF,OAAO;AACR;AAEA,SAAS,cAAc,MAAa;CACnC,OAAO,KAAK,KAAK,MAAO,MAAM,QAAQ,CAAC,IAAI,IAAI,EAAE,KAAK,IAAI,EAAE,KAAK,CAAE,CAAC,CAAC,KAAK,IAAI;AAC/E"}
|
|
@@ -1,160 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var _a;
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.StateMachine = void 0;
|
|
28
|
-
const perf = __importStar(require("perf_hooks"));
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
2
|
+
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
|
+
//#region ts/assert-order/StateMachine.ts
|
|
6
|
+
var _globalThis$process;
|
|
29
7
|
let timeTracker;
|
|
30
|
-
if (typeof ((
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
class StateMachine {
|
|
66
|
-
constructor(maxStep) {
|
|
67
|
-
Object.defineProperty(this, "listeners", {
|
|
68
|
-
enumerable: true,
|
|
69
|
-
configurable: true,
|
|
70
|
-
writable: true,
|
|
71
|
-
value: {}
|
|
72
|
-
});
|
|
73
|
-
Object.defineProperty(this, "step", {
|
|
74
|
-
enumerable: true,
|
|
75
|
-
configurable: true,
|
|
76
|
-
writable: true,
|
|
77
|
-
value: 1
|
|
78
|
-
});
|
|
79
|
-
Object.defineProperty(this, "maxStep", {
|
|
80
|
-
enumerable: true,
|
|
81
|
-
configurable: true,
|
|
82
|
-
writable: true,
|
|
83
|
-
value: void 0
|
|
84
|
-
});
|
|
85
|
-
Object.defineProperty(this, "subStep", {
|
|
86
|
-
enumerable: true,
|
|
87
|
-
configurable: true,
|
|
88
|
-
writable: true,
|
|
89
|
-
value: 0
|
|
90
|
-
});
|
|
91
|
-
Object.defineProperty(this, "minSubStep", {
|
|
92
|
-
enumerable: true,
|
|
93
|
-
configurable: true,
|
|
94
|
-
writable: true,
|
|
95
|
-
value: void 0
|
|
96
|
-
});
|
|
97
|
-
Object.defineProperty(this, "maxSubStep", {
|
|
98
|
-
enumerable: true,
|
|
99
|
-
configurable: true,
|
|
100
|
-
writable: true,
|
|
101
|
-
value: void 0
|
|
102
|
-
});
|
|
103
|
-
this.maxStep = maxStep;
|
|
104
|
-
timeTracker.start();
|
|
105
|
-
}
|
|
106
|
-
jump(step) {
|
|
107
|
-
this.step = step;
|
|
108
|
-
this.subStep = 0;
|
|
109
|
-
return this.step;
|
|
110
|
-
}
|
|
111
|
-
move() {
|
|
112
|
-
const listeners = this.listeners[this.step];
|
|
113
|
-
this.step = this.step + 1;
|
|
114
|
-
this.subStep = 0;
|
|
115
|
-
if (listeners) {
|
|
116
|
-
listeners.forEach(l => l());
|
|
117
|
-
}
|
|
118
|
-
return this.step;
|
|
119
|
-
}
|
|
120
|
-
moveSubStep() {
|
|
121
|
-
const subStep = ++this.subStep;
|
|
122
|
-
if (this.maxSubStep === this.subStep)
|
|
123
|
-
this.move();
|
|
124
|
-
return subStep;
|
|
125
|
-
}
|
|
126
|
-
get() {
|
|
127
|
-
const { step, subStep, maxStep, minSubStep, maxSubStep } = this;
|
|
128
|
-
return {
|
|
129
|
-
step,
|
|
130
|
-
maxStep,
|
|
131
|
-
subStep,
|
|
132
|
-
minSubStep,
|
|
133
|
-
maxSubStep
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
on(step, listener) {
|
|
137
|
-
this.listeners[step] = [listener];
|
|
138
|
-
}
|
|
139
|
-
isNotValid(step) {
|
|
140
|
-
return step !== this.step || (this.maxStep !== undefined && this.maxStep < step);
|
|
141
|
-
}
|
|
142
|
-
isValid(step) {
|
|
143
|
-
return step === this.step;
|
|
144
|
-
}
|
|
145
|
-
isMaxStepDefined() {
|
|
146
|
-
return this.maxStep !== undefined;
|
|
147
|
-
}
|
|
148
|
-
stopAccepting() {
|
|
149
|
-
this.maxStep = this.step - 1;
|
|
150
|
-
}
|
|
151
|
-
isAccepting() {
|
|
152
|
-
// istanbul ignore next
|
|
153
|
-
return this.maxStep ? this.maxStep >= this.step : true;
|
|
154
|
-
}
|
|
155
|
-
getTimeTaken() {
|
|
156
|
-
return timeTracker.taken();
|
|
157
|
-
}
|
|
8
|
+
if (typeof ((_globalThis$process = globalThis.process) === null || _globalThis$process === void 0 ? void 0 : _globalThis$process.hrtime) === "function") {
|
|
9
|
+
let tick;
|
|
10
|
+
timeTracker = {
|
|
11
|
+
start() {
|
|
12
|
+
tick = globalThis.process.hrtime();
|
|
13
|
+
},
|
|
14
|
+
taken() {
|
|
15
|
+
const [second, nanoSecond] = globalThis.process.hrtime(tick);
|
|
16
|
+
return second * 1e3 + nanoSecond / 1e6;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
} else if (perf_hooks.performance && typeof perf_hooks.performance.now === "function") {
|
|
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
|
+
};
|
|
158
40
|
}
|
|
41
|
+
var StateMachine = class {
|
|
42
|
+
constructor(maxStep) {
|
|
43
|
+
require_defineProperty.default(this, "listeners", {});
|
|
44
|
+
require_defineProperty.default(this, "step", 1);
|
|
45
|
+
require_defineProperty.default(this, "maxStep", void 0);
|
|
46
|
+
require_defineProperty.default(this, "subStep", 0);
|
|
47
|
+
require_defineProperty.default(this, "minSubStep", void 0);
|
|
48
|
+
require_defineProperty.default(this, "maxSubStep", void 0);
|
|
49
|
+
this.maxStep = maxStep;
|
|
50
|
+
timeTracker.start();
|
|
51
|
+
}
|
|
52
|
+
jump(step) {
|
|
53
|
+
this.step = step;
|
|
54
|
+
this.subStep = 0;
|
|
55
|
+
return this.step;
|
|
56
|
+
}
|
|
57
|
+
move() {
|
|
58
|
+
const listeners = this.listeners[this.step];
|
|
59
|
+
this.step = this.step + 1;
|
|
60
|
+
this.subStep = 0;
|
|
61
|
+
if (listeners) for (const l of listeners) l();
|
|
62
|
+
return this.step;
|
|
63
|
+
}
|
|
64
|
+
moveSubStep() {
|
|
65
|
+
const subStep = ++this.subStep;
|
|
66
|
+
if (this.maxSubStep === this.subStep) this.move();
|
|
67
|
+
return subStep;
|
|
68
|
+
}
|
|
69
|
+
get() {
|
|
70
|
+
const { step, subStep, maxStep, minSubStep, maxSubStep } = this;
|
|
71
|
+
return {
|
|
72
|
+
step,
|
|
73
|
+
maxStep,
|
|
74
|
+
subStep,
|
|
75
|
+
minSubStep,
|
|
76
|
+
maxSubStep
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
on(step, listener) {
|
|
80
|
+
this.listeners[step] = [listener];
|
|
81
|
+
}
|
|
82
|
+
isNotValid(step) {
|
|
83
|
+
return step !== this.step || this.maxStep !== void 0 && this.maxStep < step;
|
|
84
|
+
}
|
|
85
|
+
isValid(step) {
|
|
86
|
+
return step === this.step;
|
|
87
|
+
}
|
|
88
|
+
isMaxStepDefined() {
|
|
89
|
+
return this.maxStep !== void 0;
|
|
90
|
+
}
|
|
91
|
+
stopAccepting() {
|
|
92
|
+
this.maxStep = this.step - 1;
|
|
93
|
+
}
|
|
94
|
+
isAccepting() {
|
|
95
|
+
// istanbul ignore next
|
|
96
|
+
return this.maxStep ? this.maxStep >= this.step : true;
|
|
97
|
+
}
|
|
98
|
+
getTimeTaken() {
|
|
99
|
+
return timeTracker.taken();
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
//#endregion
|
|
159
103
|
exports.StateMachine = StateMachine;
|
|
104
|
+
|
|
160
105
|
//# sourceMappingURL=StateMachine.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateMachine.js","
|
|
1
|
+
{"version":3,"file":"StateMachine.js","names":["perf"],"sources":["../../ts/assert-order/StateMachine.ts"],"sourcesContent":["// Deliberately the bare specifier, not `node:perf_hooks`: package.json's `browser`\n// field maps `perf_hooks` to `false` for bundlers, and that mapping does not apply to\n// the `node:` prefixed form.\n// biome-ignore lint/style/useNodejsImportProtocol: see above\nimport * as perf from 'perf_hooks'\nimport type { State } from './types.js'\n\nlet timeTracker: { start(): void; taken(): number }\n\nif (typeof globalThis.process?.hrtime === 'function') {\n\tlet tick: [number, number]\n\ttimeTracker = {\n\t\tstart() {\n\t\t\ttick = globalThis.process.hrtime()\n\t\t},\n\t\ttaken() {\n\t\t\tconst [second, nanoSecond] = globalThis.process.hrtime(tick)\n\t\t\treturn second * 1000 + nanoSecond / 1e6\n\t\t},\n\t}\n} else if (perf.performance && typeof perf.performance.now === 'function') {\n\tconst now = perf.performance.now\n\tlet tick: number\n\ttimeTracker = {\n\t\tstart() {\n\t\t\ttick = now()\n\t\t},\n\t\ttaken() {\n\t\t\treturn now() - tick\n\t\t},\n\t}\n} else {\n\tlet tick: number\n\ttimeTracker = {\n\t\tstart() {\n\t\t\ttick = Date.now()\n\t\t},\n\t\ttaken() {\n\t\t\treturn Date.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":";;;;;;AAOA,IAAI;AAEJ,IAAI,SAAA,sBAAO,WAAW,aAAA,QAAA,wBAAA,KAAA,IAAA,KAAA,IAAA,oBAAS,YAAW,YAAY;CACrD,IAAI;CACJ,cAAc;EACb,QAAQ;GACP,OAAO,WAAW,QAAQ,OAAO;EAClC;EACA,QAAQ;GACP,MAAM,CAAC,QAAQ,cAAc,WAAW,QAAQ,OAAO,IAAI;GAC3D,OAAO,SAAS,MAAO,aAAa;EACrC;CACD;AACD,OAAO,IAAIA,WAAK,eAAe,OAAOA,WAAK,YAAY,QAAQ,YAAY;CAC1E,MAAM,MAAMA,WAAK,YAAY;CAC7B,IAAI;CACJ,cAAc;EACb,QAAQ;GACP,OAAO,IAAI;EACZ;EACA,QAAQ;GACP,OAAO,IAAI,IAAI;EAChB;CACD;AACD,OAAO;CACN,IAAI;CACJ,cAAc;EACb,QAAQ;GACP,OAAO,KAAK,IAAI;EACjB;EACA,QAAQ;GACP,OAAO,KAAK,IAAI,IAAI;EACrB;CACD;AACD;AAEA,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,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { AssertOrder } from "./AssertOrder.js";
|
|
2
|
+
import { State } from "./types.js";
|
|
3
|
+
import { InvalidOrder } from "./InvalidOrder.js";
|
|
4
|
+
export { AssertOrder, InvalidOrder, State };
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
//#region ts/assert-order/types.d.ts
|
|
2
|
+
interface State {
|
|
3
|
+
step: number;
|
|
4
|
+
maxStep?: number;
|
|
5
|
+
subStep: number;
|
|
6
|
+
minSubStep?: number;
|
|
7
|
+
maxSubStep?: number;
|
|
7
8
|
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { State };
|
|
8
11
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../ts/assert-order/types.ts"],"mappings":";UAAiB;EAChB;EACA;EACA;EACA;EACA"}
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { ErrorConstructor, ErrorValidator } from "../types.js";
|
|
2
|
+
import { SatisfyExpectation } from "./satisfies.js";
|
|
3
|
+
import { AnyConstructor } from "type-plus";
|
|
4
|
+
//#region ts/assertron/assertron.d.ts
|
|
5
|
+
type Assertron = {
|
|
6
|
+
false(value: unknown, message?: string | undefined): asserts value is false;
|
|
7
|
+
falsy(value: any, message?: string | undefined): asserts value is false | 0 | '' | null | undefined;
|
|
8
|
+
isInstanceof<T extends AnyConstructor>(value: unknown, type: T): asserts value is InstanceType<T>;
|
|
9
|
+
pathEqual(actual: string, expected: string): void;
|
|
10
|
+
rejects<R = any>(promise: Promise<any>): Promise<R>;
|
|
11
|
+
repeat<R>(fn: () => R | (() => Promise<R>), times: number): ReturnType<typeof fn> extends Promise<R> ? Promise<R> : R;
|
|
12
|
+
resolves(promise: Promise<any>): Promise<void>;
|
|
13
|
+
satisfies<Actual, Expected extends Actual>(actual: Actual, expected: SatisfyExpectation<Expected>): void;
|
|
14
|
+
throws<E extends Error>(value: PromiseLike<any>, error?: ErrorValidator | ErrorConstructor<E>): Promise<E>;
|
|
15
|
+
throws<E extends Error>(value: (...args: any[]) => never, error?: ErrorValidator | ErrorConstructor<E>): E;
|
|
16
|
+
throws<E extends Error, R = any>(value: (...args: any[]) => R, error?: ErrorValidator | ErrorConstructor<E>): R extends Promise<any> ? Promise<E> : E;
|
|
17
|
+
throws<T, R = any>(value: (...args: any[]) => R, validator?: ErrorValidator): R extends Promise<any> ? Promise<T> : T;
|
|
18
|
+
true(value: unknown, message?: string | undefined): asserts value is true;
|
|
19
|
+
truthy(value: unknown, message?: string | undefined): void;
|
|
20
|
+
uuid(value: unknown): void;
|
|
20
21
|
};
|
|
21
|
-
|
|
22
|
+
declare const assertron: Assertron;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { Assertron, assertron };
|
|
22
25
|
//# sourceMappingURL=assertron.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertron.d.ts","
|
|
1
|
+
{"version":3,"file":"assertron.d.ts","names":[],"sources":["../../ts/assertron/assertron.ts"],"mappings":";;;;KAcY;EACX,MAAM,gBAAgB,uCAAuC;EAC7D,MAAM,YAAY,uCAAuC;EACzD,aAAa,UAAU,gBAAgB,gBAAgB,MAAM,YAAY,SAAS,aAAa;EAC/F,UAAU,gBAAgB;EAC1B,QAAQ,SAAS,SAAS,eAAe,QAAQ;EACjD,OAAO,GAAG,UAAU,WAAW,QAAQ,KAAK,gBAAgB,kBAAkB,YAAY,QAAQ,KAAK,QAAQ,KAAK;EACpH,SAAS,SAAS,eAAe;EACjC,UAAU,QAAQ,iBAAiB,QAAQ,QAAQ,QAAQ,UAAU,mBAAmB;EACxF,OAAO,UAAU,OAAO,OAAO,kBAAkB,QAAQ,iBAAiB,iBAAiB,KAAK,QAAQ;EACxG,OAAO,UAAU,OAAO,WAAW,uBAAuB,QAAQ,iBAAiB,iBAAiB,KAAK;EACzG,OAAO,UAAU,OAAO,SACvB,WAAW,gBAAgB,GAC3B,QAAQ,iBAAiB,iBAAiB,KACxC,UAAU,eAAe,QAAQ,KAAK;EACzC,OAAO,GAAG,SAAS,WAAW,gBAAgB,GAAG,YAAY,iBAAiB,UAAU,eAAe,QAAQ,KAAK;EACpH,KAAK,gBAAgB,uCAAuC;EAC5D,OAAO,gBAAgB;EACvB,KAAK;;cAGO,WAAW"}
|
|
@@ -1,41 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (typeof value !== 'string')
|
|
35
|
-
throw new errors_js_1.AssertionError(`Expected ${value} to be a string`, { ssf: exports.assertron.uuid });
|
|
36
|
-
if (/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/.test(value))
|
|
37
|
-
return;
|
|
38
|
-
throw new errors_js_1.AssertionError(`Expected ${value} to be a valid UUID`, { ssf: exports.assertron.uuid });
|
|
39
|
-
}
|
|
1
|
+
const require_notEqualMessage = require("../utils/notEqualMessage.js");
|
|
2
|
+
const require_errors = require("../errors.js");
|
|
3
|
+
const require_falsy = require("./falsy.js");
|
|
4
|
+
const require_isInstanceof = require("./isInstanceof.js");
|
|
5
|
+
const require_pathEqual = require("./pathEqual.js");
|
|
6
|
+
const require_rejects = require("./rejects.js");
|
|
7
|
+
const require_repeat = require("./repeat.js");
|
|
8
|
+
const require_resolves = require("./resolves.js");
|
|
9
|
+
const require_satisfies = require("./satisfies.js");
|
|
10
|
+
const require_throws = require("./throws.js");
|
|
11
|
+
const require_truthy = require("./truthy.js");
|
|
12
|
+
//#region ts/assertron/assertron.ts
|
|
13
|
+
const assertron = {
|
|
14
|
+
false(value, message) {
|
|
15
|
+
if (value !== false) throw new require_errors.AssertionError(message !== null && message !== void 0 ? message : require_notEqualMessage.notEqualMessage(value, false), { ssf: assertron.false });
|
|
16
|
+
},
|
|
17
|
+
falsy: require_falsy.falsy,
|
|
18
|
+
isInstanceof: require_isInstanceof.isInstanceof,
|
|
19
|
+
pathEqual: require_pathEqual.pathEqual,
|
|
20
|
+
rejects: require_rejects.rejects,
|
|
21
|
+
repeat: require_repeat.repeat,
|
|
22
|
+
resolves: require_resolves.resolves,
|
|
23
|
+
satisfies: require_satisfies.satisfies,
|
|
24
|
+
throws: require_throws.throws,
|
|
25
|
+
true(value, message) {
|
|
26
|
+
if (value !== true) throw new require_errors.AssertionError(message !== null && message !== void 0 ? message : require_notEqualMessage.notEqualMessage(value, true), { ssf: assertron.true });
|
|
27
|
+
},
|
|
28
|
+
truthy: require_truthy.truthy,
|
|
29
|
+
uuid(value) {
|
|
30
|
+
if (typeof value !== "string") throw new require_errors.AssertionError(`Expected ${value} to be a string`, { ssf: assertron.uuid });
|
|
31
|
+
if (/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/.test(value)) return;
|
|
32
|
+
throw new require_errors.AssertionError(`Expected ${value} to be a valid UUID`, { ssf: assertron.uuid });
|
|
33
|
+
}
|
|
40
34
|
};
|
|
35
|
+
//#endregion
|
|
36
|
+
exports.assertron = assertron;
|
|
37
|
+
|
|
41
38
|
//# sourceMappingURL=assertron.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertron.js","
|
|
1
|
+
{"version":3,"file":"assertron.js","names":["AssertionError","notEqualMessage"],"sources":["../../ts/assertron/assertron.ts"],"sourcesContent":["import type { AnyConstructor } from 'type-plus'\nimport { AssertionError } from '../errors.js'\nimport type { ErrorConstructor, ErrorValidator } from '../types.js'\nimport { notEqualMessage } from '../utils/index.js'\nimport { falsy } from './falsy.js'\nimport { isInstanceof } from './isInstanceof.js'\nimport { pathEqual } from './pathEqual.js'\nimport { rejects } from './rejects.js'\nimport { repeat } from './repeat.js'\nimport { resolves } from './resolves.js'\nimport { type SatisfyExpectation, satisfies } from './satisfies.js'\nimport { throws } from './throws.js'\nimport { truthy } from './truthy.js'\n\nexport type Assertron = {\n\tfalse(value: unknown, message?: string | undefined): asserts value is false\n\tfalsy(value: any, message?: string | undefined): asserts value is false | 0 | '' | null | undefined\n\tisInstanceof<T extends AnyConstructor>(value: unknown, type: T): asserts value is InstanceType<T>\n\tpathEqual(actual: string, expected: string): void\n\trejects<R = any>(promise: Promise<any>): Promise<R>\n\trepeat<R>(fn: () => R | (() => Promise<R>), times: number): ReturnType<typeof fn> extends Promise<R> ? Promise<R> : R\n\tresolves(promise: Promise<any>): Promise<void>\n\tsatisfies<Actual, Expected extends Actual>(actual: Actual, expected: SatisfyExpectation<Expected>): void\n\tthrows<E extends Error>(value: PromiseLike<any>, error?: ErrorValidator | ErrorConstructor<E>): Promise<E>\n\tthrows<E extends Error>(value: (...args: any[]) => never, error?: ErrorValidator | ErrorConstructor<E>): E\n\tthrows<E extends Error, R = any>(\n\t\tvalue: (...args: any[]) => R,\n\t\terror?: ErrorValidator | ErrorConstructor<E>,\n\t): R extends Promise<any> ? Promise<E> : E\n\tthrows<T, R = any>(value: (...args: any[]) => R, validator?: ErrorValidator): R extends Promise<any> ? Promise<T> : T\n\ttrue(value: unknown, message?: string | undefined): asserts value is true\n\ttruthy(value: unknown, message?: string | undefined): void\n\tuuid(value: unknown): void\n}\n\nexport const assertron: Assertron = {\n\tfalse(value: unknown, message?: string): void {\n\t\tif (value !== false) throw new AssertionError(message ?? notEqualMessage(value, false), { ssf: assertron.false })\n\t},\n\tfalsy,\n\tisInstanceof,\n\tpathEqual,\n\trejects,\n\trepeat,\n\tresolves,\n\tsatisfies,\n\tthrows,\n\ttrue(value: unknown, message?: string): void {\n\t\tif (value !== true) throw new AssertionError(message ?? notEqualMessage(value, true), { ssf: assertron.true })\n\t},\n\ttruthy,\n\tuuid(value: unknown) {\n\t\tif (typeof value !== 'string') throw new AssertionError(`Expected ${value} to be a string`, { ssf: assertron.uuid })\n\n\t\tif (/^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$/.test(value)) return\n\n\t\tthrow new AssertionError(`Expected ${value} to be a valid UUID`, { ssf: assertron.uuid })\n\t},\n}\n"],"mappings":";;;;;;;;;;;;AAmCA,MAAa,YAAuB;CACnC,MAAM,OAAgB,SAAwB;EAC7C,IAAI,UAAU,OAAO,MAAM,IAAIA,eAAAA,eAAe,YAAA,QAAA,YAAA,KAAA,IAAA,UAAWC,wBAAAA,gBAAgB,OAAO,KAAK,GAAG,EAAE,KAAK,UAAU,MAAM,CAAC;CACjH;CACA,OAAA,cAAA;CACA,cAAA,qBAAA;CACA,WAAA,kBAAA;CACA,SAAA,gBAAA;CACA,QAAA,eAAA;CACA,UAAA,iBAAA;CACA,WAAA,kBAAA;CACA,QAAA,eAAA;CACA,KAAK,OAAgB,SAAwB;EAC5C,IAAI,UAAU,MAAM,MAAM,IAAID,eAAAA,eAAe,YAAA,QAAA,YAAA,KAAA,IAAA,UAAWC,wBAAAA,gBAAgB,OAAO,IAAI,GAAG,EAAE,KAAK,UAAU,KAAK,CAAC;CAC9G;CACA,QAAA,eAAA;CACA,KAAK,OAAgB;EACpB,IAAI,OAAO,UAAU,UAAU,MAAM,IAAID,eAAAA,eAAe,YAAY,MAAM,kBAAkB,EAAE,KAAK,UAAU,KAAK,CAAC;EAEnH,IAAI,wFAAwF,KAAK,KAAK,GAAG;EAEzG,MAAM,IAAIA,eAAAA,eAAe,YAAY,MAAM,sBAAsB,EAAE,KAAK,UAAU,KAAK,CAAC;CACzF;AACD"}
|
package/cjs/assertron/falsy.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.falsy = void 0;
|
|
4
|
-
const errors_js_1 = require("../errors.js");
|
|
1
|
+
const require_errors = require("../errors.js");
|
|
2
|
+
//#region ts/assertron/falsy.ts
|
|
5
3
|
function falsy(value, message) {
|
|
6
|
-
|
|
7
|
-
throw new errors_js_1.AssertionError(message !== null && message !== void 0 ? message : `Expected value to be falsy, but received ${value}`, { ssf: falsy });
|
|
4
|
+
if (value) throw new require_errors.AssertionError(message !== null && message !== void 0 ? message : `Expected value to be falsy, but received ${value}`, { ssf: falsy });
|
|
8
5
|
}
|
|
6
|
+
//#endregion
|
|
9
7
|
exports.falsy = falsy;
|
|
8
|
+
|
|
10
9
|
//# sourceMappingURL=falsy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"falsy.js","
|
|
1
|
+
{"version":3,"file":"falsy.js","names":["AssertionError"],"sources":["../../ts/assertron/falsy.ts"],"sourcesContent":["import { AssertionError } from '../errors.js'\n\nexport function falsy(value: unknown, message?: string): void {\n\tif (value) throw new AssertionError(message ?? `Expected value to be falsy, but received ${value}`, { ssf: falsy })\n}\n"],"mappings":";;AAEA,SAAgB,MAAM,OAAgB,SAAwB;CAC7D,IAAI,OAAO,MAAM,IAAIA,eAAAA,eAAe,YAAA,QAAA,YAAA,KAAA,IAAA,UAAW,4CAA4C,SAAS,EAAE,KAAK,MAAM,CAAC;AACnH"}
|
package/cjs/assertron/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { SatisfyExpectation } from "./satisfies.js";
|
|
2
|
+
import { Assertron, assertron } from "./assertron.js";
|
|
3
|
+
export { Assertron, type SatisfyExpectation, assertron };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isInstanceof = void 0;
|
|
4
|
-
const errors_js_1 = require("../errors.js");
|
|
1
|
+
const require_errors = require("../errors.js");
|
|
2
|
+
//#region ts/assertron/isInstanceof.ts
|
|
5
3
|
function isInstanceof(value, type) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
throw new errors_js_1.AssertionError(`Expected ${value} to be an instance of ${type.name}`, { ssf: isInstanceof });
|
|
4
|
+
if (value instanceof type) return;
|
|
5
|
+
throw new require_errors.AssertionError(`Expected ${value} to be an instance of ${type.name}`, { ssf: isInstanceof });
|
|
9
6
|
}
|
|
7
|
+
//#endregion
|
|
10
8
|
exports.isInstanceof = isInstanceof;
|
|
9
|
+
|
|
11
10
|
//# sourceMappingURL=isInstanceof.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isInstanceof.js","
|
|
1
|
+
{"version":3,"file":"isInstanceof.js","names":["AssertionError"],"sources":["../../ts/assertron/isInstanceof.ts"],"sourcesContent":["import type { AnyConstructor } from 'type-plus'\nimport { AssertionError } from '../errors.js'\n\nexport function isInstanceof<T extends AnyConstructor>(value: unknown, type: T): asserts value is InstanceType<T> {\n\tif (value instanceof type) return\n\n\tthrow new AssertionError(`Expected ${value} to be an instance of ${type.name}`, { ssf: isInstanceof })\n}\n"],"mappings":";;AAGA,SAAgB,aAAuC,OAAgB,MAA2C;CACjH,IAAI,iBAAiB,MAAM;CAE3B,MAAM,IAAIA,eAAAA,eAAe,YAAY,MAAM,wBAAwB,KAAK,QAAQ,EAAE,KAAK,aAAa,CAAC;AACtG"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const errors_js_1 = require("../errors.js");
|
|
6
|
-
const index_js_1 = require("../utils/index.js");
|
|
1
|
+
const require_notEqualMessage = require("../utils/notEqualMessage.js");
|
|
2
|
+
const require_errors = require("../errors.js");
|
|
3
|
+
let path_equal = require("path-equal");
|
|
4
|
+
//#region ts/assertron/pathEqual.ts
|
|
7
5
|
function pathEqual(actual, expected) {
|
|
8
|
-
|
|
9
|
-
throw new errors_js_1.AssertionError((0, index_js_1.notEqualMessage)(actual, expected), { ssf: pathEqual });
|
|
6
|
+
if (!(0, path_equal.pathEqual)(actual, expected)) throw new require_errors.AssertionError(require_notEqualMessage.notEqualMessage(actual, expected), { ssf: pathEqual });
|
|
10
7
|
}
|
|
8
|
+
//#endregion
|
|
11
9
|
exports.pathEqual = pathEqual;
|
|
10
|
+
|
|
12
11
|
//# sourceMappingURL=pathEqual.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathEqual.js","
|
|
1
|
+
{"version":3,"file":"pathEqual.js","names":["isPathEqual","AssertionError","notEqualMessage"],"sources":["../../ts/assertron/pathEqual.ts"],"sourcesContent":["import { pathEqual as isPathEqual } from 'path-equal'\nimport { AssertionError } from '../errors.js'\nimport { notEqualMessage } from '../utils/index.js'\n\nexport function pathEqual(actual: string, expected: string): void {\n\tif (!isPathEqual(actual, expected)) throw new AssertionError(notEqualMessage(actual, expected), { ssf: pathEqual })\n}\n"],"mappings":";;;;AAIA,SAAgB,UAAU,QAAgB,UAAwB;CACjE,IAAI,EAAA,GAACA,WAAAA,UAAAA,CAAY,QAAQ,QAAQ,GAAG,MAAM,IAAIC,eAAAA,eAAeC,wBAAAA,gBAAgB,QAAQ,QAAQ,GAAG,EAAE,KAAK,UAAU,CAAC;AACnH"}
|
package/cjs/assertron/rejects.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const errors_js_1 = require("../errors.js");
|
|
5
|
-
const index_js_1 = require("../utils/index.js");
|
|
1
|
+
const require_promiseMessages = require("../utils/promiseMessages.js");
|
|
2
|
+
const require_errors = require("../errors.js");
|
|
3
|
+
//#region ts/assertron/rejects.ts
|
|
6
4
|
function rejects(promise) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
return promise.then((value) => {
|
|
6
|
+
throw new require_errors.AssertionError(require_promiseMessages.notRejectedMessage(value), { ssf: rejects });
|
|
7
|
+
}, (err) => err);
|
|
10
8
|
}
|
|
9
|
+
//#endregion
|
|
11
10
|
exports.rejects = rejects;
|
|
11
|
+
|
|
12
12
|
//# sourceMappingURL=rejects.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rejects.js","
|
|
1
|
+
{"version":3,"file":"rejects.js","names":["AssertionError","notRejectedMessage"],"sources":["../../ts/assertron/rejects.ts"],"sourcesContent":["import { AssertionError } from '../errors.js'\nimport { notRejectedMessage } from '../utils/index.js'\n\nexport function rejects<R = any>(promise: Promise<unknown>): Promise<R> {\n\treturn promise.then(\n\t\t(value) => {\n\t\t\tthrow new AssertionError(notRejectedMessage(value), { ssf: rejects })\n\t\t},\n\t\t(err) => err,\n\t)\n}\n"],"mappings":";;;AAGA,SAAgB,QAAiB,SAAuC;CACvE,OAAO,QAAQ,MACb,UAAU;EACV,MAAM,IAAIA,eAAAA,eAAeC,wBAAAA,mBAAmB,KAAK,GAAG,EAAE,KAAK,QAAQ,CAAC;CACrE,IACC,QAAQ,GACV;AACD"}
|