@augment-vir/assert 30.8.4 → 31.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.
Files changed (65) hide show
  1. package/dist/assertions/boolean.d.ts +20 -26
  2. package/dist/assertions/boolean.js +185 -41
  3. package/dist/assertions/boundary.d.ts +40 -256
  4. package/dist/assertions/boundary.js +265 -229
  5. package/dist/assertions/enum.d.ts +12 -13
  6. package/dist/assertions/enum.js +98 -20
  7. package/dist/assertions/equality/entry-equality.d.ts +11 -15
  8. package/dist/assertions/equality/entry-equality.js +210 -43
  9. package/dist/assertions/equality/json-equality.d.ts +11 -15
  10. package/dist/assertions/equality/json-equality.js +144 -43
  11. package/dist/assertions/equality/simple-equality.d.ts +39 -46
  12. package/dist/assertions/equality/simple-equality.js +316 -61
  13. package/dist/assertions/extendable-assertions.d.ts +0 -12
  14. package/dist/assertions/extendable-assertions.js +0 -12
  15. package/dist/assertions/http.d.ts +10 -14
  16. package/dist/assertions/http.js +96 -28
  17. package/dist/assertions/instance.d.ts +10 -18
  18. package/dist/assertions/instance.js +92 -26
  19. package/dist/assertions/keys.d.ts +59 -138
  20. package/dist/assertions/keys.js +279 -163
  21. package/dist/assertions/length.d.ts +30 -212
  22. package/dist/assertions/length.js +117 -175
  23. package/dist/assertions/nullish.d.ts +8 -20
  24. package/dist/assertions/nullish.js +85 -27
  25. package/dist/assertions/numeric.d.ts +67 -81
  26. package/dist/assertions/numeric.js +564 -133
  27. package/dist/assertions/output.d.ts +2 -3
  28. package/dist/assertions/output.js +1 -7
  29. package/dist/assertions/primitive.d.ts +33 -40
  30. package/dist/assertions/primitive.js +232 -66
  31. package/dist/assertions/promise.d.ts +20 -30
  32. package/dist/assertions/promise.js +244 -53
  33. package/dist/assertions/regexp.d.ts +12 -14
  34. package/dist/assertions/regexp.js +84 -21
  35. package/dist/assertions/runtime-type.d.ts +99 -207
  36. package/dist/assertions/runtime-type.js +805 -276
  37. package/dist/assertions/throws.d.ts +24 -25
  38. package/dist/assertions/throws.js +43 -5
  39. package/dist/assertions/uuid.d.ts +11 -16
  40. package/dist/assertions/uuid.js +91 -22
  41. package/dist/assertions/values.d.ts +81 -210
  42. package/dist/assertions/values.js +627 -234
  43. package/dist/augments/assertion-exports.d.ts +0 -1
  44. package/dist/augments/assertion-exports.js +1 -1
  45. package/dist/augments/guards/assert-wrap.d.ts +7 -4
  46. package/dist/augments/guards/assert-wrap.js +5 -4
  47. package/dist/augments/guards/check-wrap.d.ts +7 -5
  48. package/dist/augments/guards/check-wrap.js +5 -4
  49. package/dist/augments/guards/check.d.ts +5 -5
  50. package/dist/augments/guards/check.js +5 -4
  51. package/dist/augments/guards/wait-until.d.ts +8 -4
  52. package/dist/augments/guards/wait-until.js +7 -8
  53. package/dist/guard-types/guard-group.d.ts +5 -2
  54. package/dist/guard-types/wait-until-function.d.ts +2 -10
  55. package/dist/guard-types/wait-until-function.js +1 -9
  56. package/dist/index.d.ts +1 -0
  57. package/package.json +2 -2
  58. package/dist/guard-types/assert-wrap-function.d.ts +0 -12
  59. package/dist/guard-types/assert-wrap-function.js +0 -14
  60. package/dist/guard-types/check-function.d.ts +0 -14
  61. package/dist/guard-types/check-function.js +0 -22
  62. package/dist/guard-types/check-wrap-wrapper-function.d.ts +0 -12
  63. package/dist/guard-types/check-wrap-wrapper-function.js +0 -19
  64. package/dist/guard-types/guard-override.d.ts +0 -4
  65. package/dist/guard-types/guard-override.js +0 -10
@@ -2,9 +2,8 @@ import { type AnyFunction } from '@augment-vir/core';
2
2
  import type { IsAny } from 'type-fest';
3
3
  import { type WaitUntilOptions } from '../guard-types/wait-until-function.js';
4
4
  /**
5
- * A customer asserter for `.output` guards (`assert.output`, `check.output`, etc.). This is
6
- * typically not necessary, as the `.output` guards already perform deep equality checks by
7
- * default.
5
+ * A custom asserter for `.output` guards (`assert.output`, `check.output`, etc.). This is typically
6
+ * not necessary, as the `.output` guards already perform deep equality checks by default.
8
7
  *
9
8
  * @category Assert : Util
10
9
  * @category Package : @augment-vir/assert
@@ -23,13 +23,7 @@ function extractOutputArgs(functionToCallOrAsserter, inputsOrFunctionToCall, exp
23
23
  const failureMessage = usingCustomAsserter
24
24
  ? emptyOrFailureMessage
25
25
  : failureMessageOrExpectedOutput;
26
- return [
27
- asserter,
28
- functionToCall,
29
- inputs,
30
- expectedOutput,
31
- failureMessage,
32
- ];
26
+ return [asserter, functionToCall, inputs, expectedOutput, failureMessage];
33
27
  }
34
28
  function innerAssertOutput(asserter, functionToCall, inputs, expectedOutput, failureMessage, shouldReturnResult) {
35
29
  const result = functionToCall(...inputs);
@@ -1,14 +1,7 @@
1
1
  import { type MaybePromise } from '@augment-vir/core';
2
2
  import { type Primitive } from 'type-fest';
3
- import { autoGuardSymbol } from '../guard-types/guard-override.js';
4
3
  import { type WaitUntilOptions } from '../guard-types/wait-until-function.js';
5
- export type { Primitive } from 'type-fest';
6
- /** Asserts that the given value is a primitive. */
7
- declare function isPrimitive(input: unknown, failureMessage?: string | undefined): asserts input is Primitive;
8
- declare function isNotPrimitive<const Actual>(input: Actual, failureMessage?: string | undefined): asserts input is Exclude<Actual, Primitive>;
9
- /** Asserts that the given value is a PropertyKey ( string | number | symbol). */
10
- declare function isPropertyKey(input: unknown, failureMessage?: string | undefined): asserts input is PropertyKey;
11
- declare function isNotPropertyKey<const Actual>(input: Actual, failureMessage?: string | undefined): asserts input is Exclude<Actual, PropertyKey>;
4
+ export { type Primitive } from 'type-fest';
12
5
  export declare const primitiveGuards: {
13
6
  assert: {
14
7
  /**
@@ -31,7 +24,7 @@ export declare const primitiveGuards: {
31
24
  * @see
32
25
  * - {@link assert.isNotPropertyKey} : the opposite assertion.
33
26
  */
34
- isPropertyKey: typeof isPropertyKey;
27
+ isPropertyKey(this: void, actual: unknown, failureMessage?: string | undefined): asserts actual is PropertyKey;
35
28
  /**
36
29
  * Asserts that a value is _not_ a valid `PropertyKey`. `PropertyKey` is a built-in TypeScript
37
30
  * type which refers to all possible key types for a JavaScript object.
@@ -52,7 +45,7 @@ export declare const primitiveGuards: {
52
45
  * @see
53
46
  * - {@link assert.isPropertyKey} : the opposite assertion.
54
47
  */
55
- isNotPropertyKey: typeof isNotPropertyKey;
48
+ isNotPropertyKey<Actual>(this: void, actual: Actual, failureMessage?: string | undefined): asserts actual is Exclude<Actual, PropertyKey>;
56
49
  /**
57
50
  * Asserts that a value is a JavaScript
58
51
  * [primitive](https://developer.mozilla.org/docs/Glossary/Primitive).
@@ -73,7 +66,7 @@ export declare const primitiveGuards: {
73
66
  * @see
74
67
  * - {@link assert.isNotPrimitive} : the opposite assertion.
75
68
  */
76
- isPrimitive: typeof isPrimitive;
69
+ isPrimitive(this: void, actual: unknown, failureMessage?: string | undefined): asserts actual is Primitive;
77
70
  /**
78
71
  * Asserts that a value is _not_ a JavaScript
79
72
  * [primitive](https://developer.mozilla.org/docs/Glossary/Primitive).
@@ -94,7 +87,7 @@ export declare const primitiveGuards: {
94
87
  * @see
95
88
  * - {@link assert.isPrimitive} : the opposite assertion.
96
89
  */
97
- isNotPrimitive: typeof isNotPrimitive;
90
+ isNotPrimitive<Actual>(this: void, actual: Actual, failureMessage?: string | undefined): asserts actual is Exclude<Actual, Primitive>;
98
91
  };
99
92
  check: {
100
93
  /**
@@ -108,15 +101,15 @@ export declare const primitiveGuards: {
108
101
  * ```ts
109
102
  * import {check} from '@augment-vir/assert';
110
103
  *
111
- * check.isPropertyKey('key'); // returns `true`
112
- * check.isPropertyKey(true); // returns `false`
113
- * check.isPropertyKey({}); // returns `false`
104
+ * check.isNotPrimitive('key'); // returns `false`
105
+ * check.isNotPrimitive(true); // returns `false`
106
+ * check.isNotPrimitive({}); // returns `true`
114
107
  * ```
115
108
  *
116
109
  * @see
117
- * - {@link check.isNotPropertyKey} : the opposite check.
110
+ * - {@link check.isPrimitive} : the opposite check.
118
111
  */
119
- isNotPrimitive: <const Actual>(input: Actual) => input is Exclude<Actual, Primitive>;
112
+ isNotPrimitive<Actual>(this: void, actual: Actual): actual is Exclude<Actual, Primitive>;
120
113
  /**
121
114
  * Checks that a value is _not_ a valid `PropertyKey`. `PropertyKey` is a built-in
122
115
  * TypeScript type which refers to all possible key types for a JavaScript object.
@@ -136,7 +129,7 @@ export declare const primitiveGuards: {
136
129
  * @see
137
130
  * - {@link check.isPropertyKey} : the opposite check.
138
131
  */
139
- isNotPropertyKey: <const Actual>(input: Actual) => input is Exclude<Actual, PropertyKey>;
132
+ isNotPropertyKey<Actual>(this: void, actual: Actual): actual is Exclude<Actual, PropertyKey>;
140
133
  /**
141
134
  * Checks that a value is a JavaScript
142
135
  * [primitive](https://developer.mozilla.org/docs/Glossary/Primitive).
@@ -156,7 +149,7 @@ export declare const primitiveGuards: {
156
149
  * @see
157
150
  * - {@link check.isNotPrimitive} : the opposite check.
158
151
  */
159
- isPrimitive: typeof autoGuardSymbol;
152
+ isPrimitive(this: void, actual: unknown): actual is Primitive;
160
153
  /**
161
154
  * Checks that a value is _not_ a JavaScript
162
155
  * [primitive](https://developer.mozilla.org/docs/Glossary/Primitive).
@@ -168,15 +161,15 @@ export declare const primitiveGuards: {
168
161
  * ```ts
169
162
  * import {check} from '@augment-vir/assert';
170
163
  *
171
- * check.isPrimitive('key'); // returns `false`
172
- * check.isPrimitive(true); // returns `false`
173
- * check.isPrimitive({}); // returns `true`
164
+ * check.isPropertyKey('key'); // returns `true`
165
+ * check.isPropertyKey(true); // returns `false`
166
+ * check.isPropertyKey({}); // returns `false`
174
167
  * ```
175
168
  *
176
169
  * @see
177
- * - {@link check.isPrimitive} : the opposite check.
170
+ * - {@link check.isNotPropertyKey} : the opposite check.
178
171
  */
179
- isPropertyKey: typeof autoGuardSymbol;
172
+ isPropertyKey<Actual>(this: void, actual: Actual): actual is Extract<PropertyKey, Actual>;
180
173
  };
181
174
  assertWrap: {
182
175
  /**
@@ -201,7 +194,7 @@ export declare const primitiveGuards: {
201
194
  * @see
202
195
  * - {@link assertWrap.isNotPropertyKey} : the opposite assertion.
203
196
  */
204
- isNotPrimitive: <const Actual>(input: Actual, failureMessage?: string | undefined) => Exclude<Actual, Primitive>;
197
+ isNotPrimitive<Actual>(this: void, actual: Actual, failureMessage?: string | undefined): Exclude<Actual, Primitive>;
205
198
  /**
206
199
  * Asserts that a value is _not_ a valid `PropertyKey`. `PropertyKey` is a built-in
207
200
  * TypeScript type which refers to all possible key types for a JavaScript object. Returns
@@ -224,7 +217,7 @@ export declare const primitiveGuards: {
224
217
  * @see
225
218
  * - {@link assertWrap.isPropertyKey} : the opposite assertion.
226
219
  */
227
- isNotPropertyKey: <const Actual>(input: Actual, failureMessage?: string | undefined) => Exclude<Actual, PropertyKey>;
220
+ isNotPropertyKey<Actual>(this: void, actual: Actual, failureMessage?: string | undefined): Exclude<Actual, PropertyKey>;
228
221
  /**
229
222
  * Asserts that a value is a JavaScript
230
223
  * [primitive](https://developer.mozilla.org/docs/Glossary/Primitive). Returns the value if
@@ -247,7 +240,7 @@ export declare const primitiveGuards: {
247
240
  * @see
248
241
  * - {@link assertWrap.isNotPrimitive} : the opposite assertion.
249
242
  */
250
- isPrimitive: typeof autoGuardSymbol;
243
+ isPrimitive<Actual>(this: void, actual: Actual, failureMessage?: string | undefined): Extract<Actual, Primitive>;
251
244
  /**
252
245
  * Asserts that a value is _not_ a JavaScript
253
246
  * [primitive](https://developer.mozilla.org/docs/Glossary/Primitive). Returns the value if
@@ -270,7 +263,7 @@ export declare const primitiveGuards: {
270
263
  * @see
271
264
  * - {@link assertWrap.isPrimitive} : the opposite assertion.
272
265
  */
273
- isPropertyKey: typeof autoGuardSymbol;
266
+ isPropertyKey<Actual>(this: void, actual: Actual, failureMessage?: string | undefined): Extract<Actual, PropertyKey>;
274
267
  };
275
268
  checkWrap: {
276
269
  /**
@@ -285,16 +278,16 @@ export declare const primitiveGuards: {
285
278
  * ```ts
286
279
  * import {checkWrap} from '@augment-vir/assert';
287
280
  *
288
- * checkWrap.isPropertyKey('key'); // returns `'key'`
289
- * checkWrap.isPropertyKey(true); // returns `undefined`
290
- * checkWrap.isPropertyKey({}); // returns `undefined`
281
+ * checkWrap.isNotPrimitive('key'); // returns `undefined`
282
+ * checkWrap.isNotPrimitive(true); // returns `undefined`
283
+ * checkWrap.isNotPrimitive({}); // returns `{}`
291
284
  * ```
292
285
  *
293
286
  * @returns The value if the check passes, otherwise `undefined`.
294
287
  * @see
295
- * - {@link checkWrap.isNotPropertyKey} : the opposite check.
288
+ * - {@link checkWrap.isPrimitive} : the opposite check.
296
289
  */
297
- isNotPrimitive: <const Actual>(input: Actual) => Exclude<Actual, Primitive> | undefined;
290
+ isNotPrimitive<Actual>(this: void, actual: Actual): Exclude<Actual, Primitive> | undefined;
298
291
  /**
299
292
  * Checks that a value is _not_ a valid `PropertyKey`. `PropertyKey` is a built-in
300
293
  * TypeScript type which refers to all possible key types for a JavaScript object. Returns
@@ -316,7 +309,7 @@ export declare const primitiveGuards: {
316
309
  * @see
317
310
  * - {@link checkWrap.isPropertyKey} : the opposite check.
318
311
  */
319
- isNotPropertyKey: <const Actual>(input: Actual) => Exclude<Actual, PropertyKey> | undefined;
312
+ isNotPropertyKey<Actual>(this: void, actual: Actual): Exclude<Actual, PropertyKey> | undefined;
320
313
  /**
321
314
  * Checks that a value is a JavaScript
322
315
  * [primitive](https://developer.mozilla.org/docs/Glossary/Primitive). Returns the value if
@@ -338,7 +331,7 @@ export declare const primitiveGuards: {
338
331
  * @see
339
332
  * - {@link checkWrap.isNotPrimitive} : the opposite check.
340
333
  */
341
- isPrimitive: typeof autoGuardSymbol;
334
+ isPrimitive<Actual>(this: void, actual: Actual): Extract<Actual, Primitive> | undefined;
342
335
  /**
343
336
  * Checks that a value is _not_ a JavaScript
344
337
  * [primitive](https://developer.mozilla.org/docs/Glossary/Primitive). Returns the value if
@@ -360,7 +353,7 @@ export declare const primitiveGuards: {
360
353
  * @see
361
354
  * - {@link checkWrap.isPrimitive} : the opposite check.
362
355
  */
363
- isPropertyKey: typeof autoGuardSymbol;
356
+ isPropertyKey<Actual>(this: void, actual: Actual): Extract<PropertyKey, Actual> | undefined;
364
357
  };
365
358
  waitUntil: {
366
359
  /**
@@ -386,7 +379,7 @@ export declare const primitiveGuards: {
386
379
  * @see
387
380
  * - {@link waitUntil.isNotPropertyKey} : the opposite assertion.
388
381
  */
389
- isNotPrimitive: <const Actual>(callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, Primitive>>;
382
+ isNotPrimitive: <Actual>(this: void, callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, Primitive>>;
390
383
  /**
391
384
  * Repeatedly calls a callback until its output is _not_ a valid `PropertyKey`.
392
385
  * `PropertyKey` is a built-in TypeScript type which refers to all possible key types for a
@@ -410,7 +403,7 @@ export declare const primitiveGuards: {
410
403
  * @see
411
404
  * - {@link waitUntil.isPropertyKey} : the opposite assertion.
412
405
  */
413
- isNotPropertyKey: <const Actual>(callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, PropertyKey>>;
406
+ isNotPropertyKey: <Actual>(this: void, callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, PropertyKey>>;
414
407
  /**
415
408
  * Repeatedly calls a callback until its output is a JavaScript
416
409
  * [primitive](https://developer.mozilla.org/docs/Glossary/Primitive). Once the callback
@@ -433,7 +426,7 @@ export declare const primitiveGuards: {
433
426
  * @see
434
427
  * - {@link waitUntil.isNotPrimitive} : the opposite assertion.
435
428
  */
436
- isPrimitive: typeof autoGuardSymbol;
429
+ isPrimitive: <Actual>(this: void, callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Extract<Actual, Primitive>>;
437
430
  /**
438
431
  * Repeatedly calls a callback until its output is _not_ a JavaScript
439
432
  * [primitive](https://developer.mozilla.org/docs/Glossary/Primitive). Once the callback
@@ -456,6 +449,6 @@ export declare const primitiveGuards: {
456
449
  * @see
457
450
  * - {@link waitUntil.isPrimitive} : the opposite assertion.
458
451
  */
459
- isPropertyKey: typeof autoGuardSymbol;
452
+ isPropertyKey: <Actual>(this: void, callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Extract<Actual, PropertyKey>>;
460
453
  };
461
454
  };