@augment-vir/assert 30.0.0 → 30.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/README.md +11 -0
  2. package/dist/assertions/boolean.d.ts +443 -17
  3. package/dist/assertions/boolean.js +365 -8
  4. package/dist/assertions/boundary.d.ts +657 -13
  5. package/dist/assertions/boundary.js +537 -5
  6. package/dist/assertions/enum.d.ts +236 -8
  7. package/dist/assertions/enum.js +197 -5
  8. package/dist/assertions/equality/entry-equality.d.ts +287 -11
  9. package/dist/assertions/equality/entry-equality.js +243 -6
  10. package/dist/assertions/equality/json-equality.d.ts +244 -15
  11. package/dist/assertions/equality/json-equality.js +207 -11
  12. package/dist/assertions/equality/simple-equality.d.ts +849 -28
  13. package/dist/assertions/equality/simple-equality.js +712 -6
  14. package/dist/assertions/equality/ts-type-equality.d.ts +37 -1
  15. package/dist/assertions/equality/ts-type-equality.js +13 -1
  16. package/dist/assertions/extendable-assertions.d.ts +288 -120
  17. package/dist/assertions/extendable-assertions.js +32 -60
  18. package/dist/assertions/http.d.ts +217 -10
  19. package/dist/assertions/http.js +182 -6
  20. package/dist/assertions/instance.d.ts +189 -8
  21. package/dist/assertions/instance.js +159 -5
  22. package/dist/assertions/keys.d.ts +658 -13
  23. package/dist/assertions/keys.js +556 -5
  24. package/dist/assertions/length.d.ts +381 -9
  25. package/dist/assertions/length.js +309 -5
  26. package/dist/assertions/nullish.d.ts +169 -7
  27. package/dist/assertions/nullish.js +137 -6
  28. package/dist/assertions/numeric.d.ts +965 -11
  29. package/dist/assertions/numeric.js +819 -1
  30. package/dist/assertions/output.d.ts +107 -7
  31. package/dist/assertions/output.js +92 -5
  32. package/dist/assertions/primitive.d.ts +416 -13
  33. package/dist/assertions/primitive.js +352 -6
  34. package/dist/assertions/promise.d.ts +640 -21
  35. package/dist/assertions/promise.js +536 -15
  36. package/dist/assertions/regexp.d.ts +202 -3
  37. package/dist/assertions/regexp.js +173 -1
  38. package/dist/assertions/runtime-type.d.ts +1822 -41
  39. package/dist/assertions/runtime-type.js +1558 -35
  40. package/dist/assertions/throws.d.ts +265 -17
  41. package/dist/assertions/throws.js +229 -17
  42. package/dist/assertions/uuid.d.ts +233 -10
  43. package/dist/assertions/uuid.js +195 -6
  44. package/dist/assertions/values.d.ts +1086 -15
  45. package/dist/assertions/values.js +907 -6
  46. package/dist/augments/assertion.error.d.ts +2 -1
  47. package/dist/augments/assertion.error.js +2 -1
  48. package/dist/augments/guards/assert-wrap.d.ts +82 -37
  49. package/dist/augments/guards/assert-wrap.js +13 -2
  50. package/dist/augments/guards/assert.d.ts +30 -14
  51. package/dist/augments/guards/assert.js +21 -4
  52. package/dist/augments/guards/check-wrap.d.ts +94 -51
  53. package/dist/augments/guards/check-wrap.js +11 -3
  54. package/dist/augments/guards/check.d.ts +87 -37
  55. package/dist/augments/guards/check.js +9 -2
  56. package/dist/augments/guards/wait-until.d.ts +110 -103
  57. package/dist/augments/guards/wait-until.js +18 -3
  58. package/dist/augments/if-equals.d.ts +4 -2
  59. package/dist/guard-types/assert-wrap-function.d.ts +5 -2
  60. package/dist/guard-types/check-function.d.ts +5 -2
  61. package/dist/guard-types/check-wrap-wrapper-function.d.ts +4 -1
  62. package/dist/guard-types/guard-group.d.ts +7 -8
  63. package/dist/guard-types/wait-until-function.d.ts +8 -3
  64. package/dist/guard-types/wait-until-function.js +1 -1
  65. package/package.json +17 -4
@@ -1,4 +1,5 @@
1
1
  import { AssertionError } from '../augments/assertion.error.js';
2
+ import { autoGuardSymbol } from '../guard-types/guard-override.js';
2
3
  function isAbove(actual, expected, failureMessage) {
3
4
  if (actual <= expected) {
4
5
  throw new AssertionError(`${actual} is not above ${expected}`, failureMessage);
@@ -56,5 +57,822 @@ const assertions = {
56
57
  isNotApproximately,
57
58
  };
58
59
  export const numericGuards = {
59
- assertions,
60
+ assert: assertions,
61
+ check: {
62
+ /**
63
+ * Checks that a number is above the expectation (`actual > expected`).
64
+ *
65
+ * Performs no type guarding.
66
+ *
67
+ * @example
68
+ *
69
+ * ```ts
70
+ * import {check} from '@augment-vir/assert';
71
+ *
72
+ * check.isAbove(10, 5); // returns `true`
73
+ * check.isAbove(5, 5); // returns `false`
74
+ * check.isAbove(5, 10); // returns `false`
75
+ * ```
76
+ *
77
+ * @see
78
+ * - {@link check.isBelow} : the opposite check.
79
+ * - {@link check.isAtLeast} : the more lenient check.
80
+ */
81
+ isAbove: autoGuardSymbol,
82
+ /**
83
+ * Checks that a number is at least the expectation (`actual >= expected`).
84
+ *
85
+ * Performs no type guarding.
86
+ *
87
+ * @example
88
+ *
89
+ * ```ts
90
+ * import {check} from '@augment-vir/assert';
91
+ *
92
+ * check.isAtLeast(10, 5); // returns `true`
93
+ * check.isAtLeast(5, 5); // returns `true`
94
+ * check.isAtLeast(5, 10); // returns `false`
95
+ * ```
96
+ *
97
+ * @see
98
+ * - {@link check.isAtMost} : the opposite check.
99
+ * - {@link check.isAbove} : the more restrictive check.
100
+ */
101
+ isAtLeast: autoGuardSymbol,
102
+ /**
103
+ * Checks that a number is below the expectation (`actual < expected`).
104
+ *
105
+ * Performs no type guarding.
106
+ *
107
+ * @example
108
+ *
109
+ * ```ts
110
+ * import {check} from '@augment-vir/assert';
111
+ *
112
+ * check.isBelow(10, 5); // returns `false`
113
+ * check.isBelow(5, 5); // returns `false`
114
+ * check.isBelow(5, 10); // returns `true`
115
+ * ```
116
+ *
117
+ * @see
118
+ * - {@link check.isAbove} : the opposite check.
119
+ * - {@link check.isAtMost} : the more lenient check.
120
+ */
121
+ isBelow: autoGuardSymbol,
122
+ /**
123
+ * Checks that a number is at most the expectation (`actual <= expected`).
124
+ *
125
+ * Performs no type guarding.
126
+ *
127
+ * @example
128
+ *
129
+ * ```ts
130
+ * import {check} from '@augment-vir/assert';
131
+ *
132
+ * check.isAtMost(10, 5); // returns `false`
133
+ * check.isAtMost(5, 5); // returns `true`
134
+ * check.isAtMost(5, 10); // returns `true`
135
+ * ```
136
+ *
137
+ * @see
138
+ * - {@link check.isAtLeast} : the opposite check.
139
+ * - {@link check.isBelow} : the more restrictive check.
140
+ */
141
+ isAtMost: autoGuardSymbol,
142
+ /**
143
+ * Checks that a number is
144
+ * [`NaN`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NaN).
145
+ *
146
+ * Performs no type guarding.
147
+ *
148
+ * @example
149
+ *
150
+ * ```ts
151
+ * import {check} from '@augment-vir/assert';
152
+ *
153
+ * check.isNaN(10); // returns `false`
154
+ * check.isNaN(parseInt('invalid')); // returns `true`
155
+ * check.isNaN(Infinity); // returns `false`
156
+ * ```
157
+ *
158
+ * @see
159
+ * - {@link check.isNumber} : can be used as the opposite check.
160
+ */
161
+ isNaN: autoGuardSymbol,
162
+ /**
163
+ * Checks that a number is finite: meaning, not `NaN` and not `Infinity` or `-Infinity`.
164
+ *
165
+ * Performs no type guarding.
166
+ *
167
+ * @example
168
+ *
169
+ * ```ts
170
+ * import {check} from '@augment-vir/assert';
171
+ *
172
+ * check.isFinite(10); // returns `true`
173
+ * check.isFinite(parseInt('invalid')); // returns `false`
174
+ * check.isFinite(Infinity); // returns `false`
175
+ * check.isFinite(-Infinity); // returns `false`
176
+ * ```
177
+ *
178
+ * @see
179
+ * - {@link check.isNaN} : an opposite check.
180
+ * - {@link check.isInfinite} : an opposite check.
181
+ */
182
+ isFinite: autoGuardSymbol,
183
+ /**
184
+ * Checks that a number is either `Infinity` or `-Infinity`.
185
+ *
186
+ * Performs no type guarding.
187
+ *
188
+ * @example
189
+ *
190
+ * ```ts
191
+ * import {check} from '@augment-vir/assert';
192
+ *
193
+ * check.isInfinite(10); // returns `false`
194
+ * check.isInfinite(parseInt('invalid')); // returns `false`
195
+ * check.isInfinite(Infinity); // returns `true`
196
+ * check.isInfinite(-Infinity); // returns `true`
197
+ * ```
198
+ *
199
+ * @see
200
+ * - {@link check.isNaN} : an opposite check.
201
+ * - {@link check.isInfinite} : an opposite check.
202
+ */
203
+ isInfinite: autoGuardSymbol,
204
+ /**
205
+ * Checks that a number is within ±`delta` of the expectation.
206
+ *
207
+ * Performs no type guarding.
208
+ *
209
+ * @example
210
+ *
211
+ * ```ts
212
+ * import {check} from '@augment-vir/assert';
213
+ *
214
+ * check.isApproximately(10, 8, 4); // returns `true`
215
+ * check.isApproximately(10, 12, 4); // returns `true`
216
+ * check.isApproximately(10, 8, 1); // returns `false`
217
+ * check.isApproximately(10, 12, 1); // returns `false`
218
+ * ```
219
+ *
220
+ * @see
221
+ * - {@link check.isNotApproximately} : the opposite check.
222
+ */
223
+ isApproximately: autoGuardSymbol,
224
+ /**
225
+ * Checks that a number is outside ±`delta` of the expectation.
226
+ *
227
+ * Performs no type guarding.
228
+ *
229
+ * @example
230
+ *
231
+ * ```ts
232
+ * import {check} from '@augment-vir/assert';
233
+ *
234
+ * check.isNotApproximately(10, 8, 4); // returns `false`
235
+ * check.isNotApproximately(10, 12, 4); // returns `false`
236
+ * check.isNotApproximately(10, 8, 1); // returns `true`
237
+ * check.isNotApproximately(10, 12, 1); // returns `true`
238
+ * ```
239
+ *
240
+ * @see
241
+ * - {@link check.isApproximately} : the opposite check.
242
+ */
243
+ isNotApproximately: autoGuardSymbol,
244
+ },
245
+ assertWrap: {
246
+ /**
247
+ * Asserts that a number is above the expectation (`actual > expected`). Returns the number
248
+ * if the assertion passes.
249
+ *
250
+ * Performs no type guarding.
251
+ *
252
+ * @example
253
+ *
254
+ * ```ts
255
+ * import {assertWrap} from '@augment-vir/assert';
256
+ *
257
+ * assertWrap.isAbove(10, 5); // returns `10`
258
+ * assertWrap.isAbove(5, 5); // throws an error
259
+ * assertWrap.isAbove(5, 10); // throws an error
260
+ * ```
261
+ *
262
+ * @returns The value if the assertion passes.
263
+ * @throws {@link AssertionError} If the assertion fails.
264
+ * @see
265
+ * - {@link assertWrap.isBelow} : the opposite assertion.
266
+ * - {@link assertWrap.isAtLeast} : the more lenient assertion.
267
+ */
268
+ isAbove: autoGuardSymbol,
269
+ /**
270
+ * Asserts that a number is at least the expectation (`actual >= expected`). Returns the
271
+ * number if the assertion passes.
272
+ *
273
+ * Performs no type guarding.
274
+ *
275
+ * @example
276
+ *
277
+ * ```ts
278
+ * import {assertWrap} from '@augment-vir/assert';
279
+ *
280
+ * assertWrap.isAtLeast(10, 5); // returns `10`
281
+ * assertWrap.isAtLeast(5, 5); // returns `5`
282
+ * assertWrap.isAtLeast(5, 10); // throws an error
283
+ * ```
284
+ *
285
+ * @returns The value if the assertion passes.
286
+ * @throws {@link AssertionError} If the assertion fails.
287
+ * @see
288
+ * - {@link assertWrap.isAtMost} : the opposite assertion.
289
+ * - {@link assertWrap.isAbove} : the more restrictive assertion.
290
+ */
291
+ isAtLeast: autoGuardSymbol,
292
+ /**
293
+ * Asserts that a number is below the expectation (`actual < expected`). Returns the number
294
+ * if the assertion passes.
295
+ *
296
+ * Performs no type guarding.
297
+ *
298
+ * @example
299
+ *
300
+ * ```ts
301
+ * import {assertWrap} from '@augment-vir/assert';
302
+ *
303
+ * assertWrap.isBelow(10, 5); // throws an error
304
+ * assertWrap.isBelow(5, 5); // throws an error
305
+ * assertWrap.isBelow(5, 10); // returns `5`
306
+ * ```
307
+ *
308
+ * @returns The value if the assertion passes.
309
+ * @throws {@link AssertionError} If the assertion fails.
310
+ * @see
311
+ * - {@link assertWrap.isAbove} : the opposite assertion.
312
+ * - {@link assertWrap.isAtMost} : the more lenient assertion.
313
+ */
314
+ isBelow: autoGuardSymbol,
315
+ /**
316
+ * Asserts that a number is at most the expectation (`actual <= expected`). Returns the
317
+ * number if the assertion passes.
318
+ *
319
+ * Performs no type guarding.
320
+ *
321
+ * @example
322
+ *
323
+ * ```ts
324
+ * import {assertWrap} from '@augment-vir/assert';
325
+ *
326
+ * assertWrap.isAtMost(10, 5); // throws an error
327
+ * assertWrap.isAtMost(5, 5); // returns `5`
328
+ * assertWrap.isAtMost(5, 10); // returns `5`
329
+ * ```
330
+ *
331
+ * @returns The value if the assertion passes.
332
+ * @throws {@link AssertionError} If the assertion fails.
333
+ * @see
334
+ * - {@link assertWrap.isAtLeast} : the opposite assertion.
335
+ * - {@link assertWrap.isBelow} : the more restrictive assertion.
336
+ */
337
+ isAtMost: autoGuardSymbol,
338
+ /**
339
+ * Asserts that a number is
340
+ * [`NaN`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NaN).
341
+ * Returns the number if the assertion passes.
342
+ *
343
+ * Performs no type guarding.
344
+ *
345
+ * @example
346
+ *
347
+ * ```ts
348
+ * import {assertWrap} from '@augment-vir/assert';
349
+ *
350
+ * assertWrap.isNaN(10); // throws an error
351
+ * assertWrap.isNaN(parseInt('invalid')); // returns `NaN`
352
+ * assertWrap.isNaN(Infinity); // throws an error
353
+ * ```
354
+ *
355
+ * @returns The value if the assertion passes.
356
+ * @throws {@link AssertionError} If the assertion fails.
357
+ * @see
358
+ * - {@link assertWrap.isNumber} : can be used as the opposite assertion.
359
+ */
360
+ isNaN: autoGuardSymbol,
361
+ /**
362
+ * Asserts that a number is finite: meaning, not `NaN` and not `Infinity` or `-Infinity`.
363
+ * Returns the number if the assertion passes.
364
+ *
365
+ * Performs no type guarding.
366
+ *
367
+ * @example
368
+ *
369
+ * ```ts
370
+ * import {assertWrap} from '@augment-vir/assert';
371
+ *
372
+ * assertWrap.isFinite(10); // returns `10`
373
+ * assertWrap.isFinite(parseInt('invalid')); // throws an error
374
+ * assertWrap.isFinite(Infinity); // throws an error
375
+ * assertWrap.isFinite(-Infinity); // throws an error
376
+ * ```
377
+ *
378
+ * @returns The value if the assertion passes.
379
+ * @throws {@link AssertionError} If the assertion fails.
380
+ * @see
381
+ * - {@link assertWrap.isNaN} : an opposite assertion.
382
+ * - {@link assertWrap.isInfinite} : an opposite assertion.
383
+ */
384
+ isFinite: autoGuardSymbol,
385
+ /**
386
+ * Asserts that a number is either `Infinity` or `-Infinity`. Returns the number if the
387
+ * assertion passes.
388
+ *
389
+ * Performs no type guarding.
390
+ *
391
+ * @example
392
+ *
393
+ * ```ts
394
+ * import {assertWrap} from '@augment-vir/assert';
395
+ *
396
+ * assertWrap.isInfinite(10); // throws an error
397
+ * assertWrap.isInfinite(parseInt('invalid')); // throws an error
398
+ * assertWrap.isInfinite(Infinity); // returns `Infinity`
399
+ * assertWrap.isInfinite(-Infinity); // returns `-Infinity`
400
+ * ```
401
+ *
402
+ * @returns The value if the assertion passes.
403
+ * @throws {@link AssertionError} If the assertion fails.
404
+ * @see
405
+ * - {@link assertWrap.isNaN} : an opposite assertion.
406
+ * - {@link assertWrap.isInfinite} : an opposite assertion.
407
+ */
408
+ isInfinite: autoGuardSymbol,
409
+ /**
410
+ * Asserts that a number is within ±`delta` of the expectation. Returns the number if the
411
+ * assertion passes.
412
+ *
413
+ * Performs no type guarding.
414
+ *
415
+ * @example
416
+ *
417
+ * ```ts
418
+ * import {assertWrap} from '@augment-vir/assert';
419
+ *
420
+ * assertWrap.isApproximately(10, 8, 4); // returns `10`
421
+ * assertWrap.isApproximately(10, 12, 4); // returns `10`
422
+ * assertWrap.isApproximately(10, 8, 1); // throws an error
423
+ * assertWrap.isApproximately(10, 12, 1); // throws an error
424
+ * ```
425
+ *
426
+ * @returns The value if the assertion passes.
427
+ * @throws {@link AssertionError} If the assertion fails.
428
+ * @see
429
+ * - {@link assertWrap.isNotApproximately} : the opposite assertion.
430
+ */
431
+ isApproximately: autoGuardSymbol,
432
+ /**
433
+ * Asserts that a number is outside ±`delta` of the expectation. Returns the number if the
434
+ * assertion passes.
435
+ *
436
+ * Performs no type guarding.
437
+ *
438
+ * @example
439
+ *
440
+ * ```ts
441
+ * import {assertWrap} from '@augment-vir/assert';
442
+ *
443
+ * assertWrap.isNotApproximately(10, 8, 4); // throws an error
444
+ * assertWrap.isNotApproximately(10, 12, 4); // throws an error
445
+ * assertWrap.isNotApproximately(10, 8, 1); // returns `10`
446
+ * assertWrap.isNotApproximately(10, 12, 1); // returns `10`
447
+ * ```
448
+ *
449
+ * @returns The value if the assertion passes.
450
+ * @throws {@link AssertionError} If the assertion fails.
451
+ * @see
452
+ * - {@link assertWrap.isApproximately} : the opposite assertion.
453
+ */
454
+ isNotApproximately: autoGuardSymbol,
455
+ },
456
+ checkWrap: {
457
+ /**
458
+ * Checks that a number is above the expectation (`actual > expected`). Returns the number
459
+ * if the check passes, otherwise `undefined`.
460
+ *
461
+ * Performs no type guarding.
462
+ *
463
+ * @example
464
+ *
465
+ * ```ts
466
+ * import {checkWrap} from '@augment-vir/assert';
467
+ *
468
+ * checkWrap.isAbove(10, 5); // returns `10`
469
+ * checkWrap.isAbove(5, 5); // returns `undefined`
470
+ * checkWrap.isAbove(5, 10); // returns `undefined`
471
+ * ```
472
+ *
473
+ * @returns The value if the check passes, otherwise `undefined`.
474
+ * @see
475
+ * - {@link checkWrap.isBelow} : the opposite check.
476
+ * - {@link checkWrap.isAtLeast} : the more lenient check.
477
+ */
478
+ isAbove: autoGuardSymbol,
479
+ /**
480
+ * Checks that a number is at least the expectation (`actual >= expected`). Returns the
481
+ * number if the check passes, otherwise `undefined`.
482
+ *
483
+ * Performs no type guarding.
484
+ *
485
+ * @example
486
+ *
487
+ * ```ts
488
+ * import {checkWrap} from '@augment-vir/assert';
489
+ *
490
+ * checkWrap.isAtLeast(10, 5); // returns `10`
491
+ * checkWrap.isAtLeast(5, 5); // returns `5`
492
+ * checkWrap.isAtLeast(5, 10); // returns `undefined`
493
+ * ```
494
+ *
495
+ * @returns The value if the check passes, otherwise `undefined`.
496
+ * @see
497
+ * - {@link checkWrap.isAtMost} : the opposite check.
498
+ * - {@link checkWrap.isAbove} : the more restrictive check.
499
+ */
500
+ isAtLeast: autoGuardSymbol,
501
+ /**
502
+ * Checks that a number is below the expectation (`actual < expected`). Returns the number
503
+ * if the check passes, otherwise `undefined`.
504
+ *
505
+ * Performs no type guarding.
506
+ *
507
+ * @example
508
+ *
509
+ * ```ts
510
+ * import {checkWrap} from '@augment-vir/assert';
511
+ *
512
+ * checkWrap.isBelow(10, 5); // returns `undefined`
513
+ * checkWrap.isBelow(5, 5); // returns `undefined`
514
+ * checkWrap.isBelow(5, 10); // returns `5`
515
+ * ```
516
+ *
517
+ * @returns The value if the check passes, otherwise `undefined`.
518
+ * @see
519
+ * - {@link checkWrap.isAbove} : the opposite check.
520
+ * - {@link checkWrap.isAtMost} : the more lenient check.
521
+ */
522
+ isBelow: autoGuardSymbol,
523
+ /**
524
+ * Checks that a number is at most the expectation (`actual <= expected`). Returns the
525
+ * number if the check passes, otherwise `undefined`.
526
+ *
527
+ * Performs no type guarding.
528
+ *
529
+ * @example
530
+ *
531
+ * ```ts
532
+ * import {checkWrap} from '@augment-vir/assert';
533
+ *
534
+ * checkWrap.isAtMost(10, 5); // returns `undefined`
535
+ * checkWrap.isAtMost(5, 5); // returns `5`
536
+ * checkWrap.isAtMost(5, 10); // returns `5`
537
+ * ```
538
+ *
539
+ * @returns The value if the check passes, otherwise `undefined`.
540
+ * @see
541
+ * - {@link checkWrap.isAtLeast} : the opposite check.
542
+ * - {@link checkWrap.isBelow} : the more restrictive check.
543
+ */
544
+ isAtMost: autoGuardSymbol,
545
+ /**
546
+ * Checks that a number is
547
+ * [`NaN`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NaN).
548
+ * Returns the number if the check passes, otherwise `undefined`.
549
+ *
550
+ * Performs no type guarding.
551
+ *
552
+ * @example
553
+ *
554
+ * ```ts
555
+ * import {checkWrap} from '@augment-vir/assert';
556
+ *
557
+ * checkWrap.isNaN(10); // returns `undefined`
558
+ * checkWrap.isNaN(parseInt('invalid')); // returns `NaN`
559
+ * checkWrap.isNaN(Infinity); // returns `undefined`
560
+ * ```
561
+ *
562
+ * @returns The value if the check passes, otherwise `undefined`.
563
+ * @see
564
+ * - {@link checkWrap.isNumber} : can be used as the opposite check.
565
+ */
566
+ isNaN: autoGuardSymbol,
567
+ /**
568
+ * Checks that a number is finite: meaning, not `NaN` and not `Infinity` or `-Infinity`.
569
+ * Returns the number if the check passes, otherwise `undefined`.
570
+ *
571
+ * Performs no type guarding.
572
+ *
573
+ * @example
574
+ *
575
+ * ```ts
576
+ * import {checkWrap} from '@augment-vir/assert';
577
+ *
578
+ * checkWrap.isFinite(10); // returns `10`
579
+ * checkWrap.isFinite(parseInt('invalid')); // returns `undefined`
580
+ * checkWrap.isFinite(Infinity); // returns `undefined`
581
+ * checkWrap.isFinite(-Infinity); // returns `undefined`
582
+ * ```
583
+ *
584
+ * @returns The value if the check passes, otherwise `undefined`.
585
+ * @see
586
+ * - {@link checkWrap.isNaN} : an opposite check.
587
+ * - {@link checkWrap.isInfinite} : an opposite check.
588
+ */
589
+ isFinite: autoGuardSymbol,
590
+ /**
591
+ * Checks that a number is either `Infinity` or `-Infinity`. Returns the number if the check
592
+ * passes, otherwise `undefined`.
593
+ *
594
+ * Performs no type guarding.
595
+ *
596
+ * @example
597
+ *
598
+ * ```ts
599
+ * import {checkWrap} from '@augment-vir/assert';
600
+ *
601
+ * checkWrap.isInfinite(10); // returns `undefined`
602
+ * checkWrap.isInfinite(parseInt('invalid')); // returns `undefined`
603
+ * checkWrap.isInfinite(Infinity); // returns `Infinity`
604
+ * checkWrap.isInfinite(-Infinity); // returns `-Infinity`
605
+ * ```
606
+ *
607
+ * @returns The value if the check passes, otherwise `undefined`.
608
+ * @see
609
+ * - {@link checkWrap.isNaN} : an opposite check.
610
+ * - {@link checkWrap.isInfinite} : an opposite check.
611
+ */
612
+ isInfinite: autoGuardSymbol,
613
+ /**
614
+ * Checks that a number is within ±`delta` of the expectation. Returns the number if the
615
+ * check passes, otherwise `undefined`.
616
+ *
617
+ * Performs no type guarding.
618
+ *
619
+ * @example
620
+ *
621
+ * ```ts
622
+ * import {checkWrap} from '@augment-vir/assert';
623
+ *
624
+ * checkWrap.isApproximately(10, 8, 4); // returns `10`
625
+ * checkWrap.isApproximately(10, 12, 4); // returns `10`
626
+ * checkWrap.isApproximately(10, 8, 1); // returns `undefined`
627
+ * checkWrap.isApproximately(10, 12, 1); // returns `undefined`
628
+ * ```
629
+ *
630
+ * @returns The value if the check passes, otherwise `undefined`.
631
+ * @see
632
+ * - {@link checkWrap.isNotApproximately} : the opposite check.
633
+ */
634
+ isApproximately: autoGuardSymbol,
635
+ /**
636
+ * Checks that a number is outside ±`delta` of the expectation. Returns the number if the
637
+ * check passes, otherwise `undefined`.
638
+ *
639
+ * Performs no type guarding.
640
+ *
641
+ * @example
642
+ *
643
+ * ```ts
644
+ * import {checkWrap} from '@augment-vir/assert';
645
+ *
646
+ * checkWrap.isNotApproximately(10, 8, 4); // returns `undefined`
647
+ * checkWrap.isNotApproximately(10, 12, 4); // returns `undefined`
648
+ * checkWrap.isNotApproximately(10, 8, 1); // returns `10`
649
+ * checkWrap.isNotApproximately(10, 12, 1); // returns `10`
650
+ * ```
651
+ *
652
+ * @returns The value if the check passes, otherwise `undefined`.
653
+ * @see
654
+ * - {@link checkWrap.isApproximately} : the opposite check.
655
+ */
656
+ isNotApproximately: autoGuardSymbol,
657
+ },
658
+ waitUntil: {
659
+ /**
660
+ * Repeatedly calls a callback until its output is a number that is above the expectation
661
+ * (`actual > expected`). Once the callback output passes, it is returned. If the attempts
662
+ * time out, an error is thrown.
663
+ *
664
+ * Performs no type guarding.
665
+ *
666
+ * @example
667
+ *
668
+ * ```ts
669
+ * import {waitUntil} from '@augment-vir/assert';
670
+ *
671
+ * await waitUntil.isAbove(5, () => 10); // returns `10`
672
+ * await waitUntil.isAbove(5, () => 5); // throws an error
673
+ * await waitUntil.isAbove(10, () => 5); // throws an error
674
+ * ```
675
+ *
676
+ * @returns The callback output once it passes.
677
+ * @throws {@link AssertionError} On timeout.
678
+ * @see
679
+ * - {@link waitUntil.isBelow} : the opposite assertion.
680
+ * - {@link waitUntil.isAtLeast} : the more lenient assertion.
681
+ */
682
+ isAbove: autoGuardSymbol,
683
+ /**
684
+ * Repeatedly calls a callback until its output is a number that is at least the expectation
685
+ * (`actual >= expected`). Once the callback output passes, it is returned. If the attempts
686
+ * time out, an error is thrown.
687
+ *
688
+ * Performs no type guarding.
689
+ *
690
+ * @example
691
+ *
692
+ * ```ts
693
+ * import {waitUntil} from '@augment-vir/assert';
694
+ *
695
+ * await waitUntil.isAtLeast(5, () => 10); // returns `10`
696
+ * await waitUntil.isAtLeast(5, () => 5); // returns `5`
697
+ * await waitUntil.isAtLeast(10, () => 5); // throws an error
698
+ * ```
699
+ *
700
+ * @returns The callback output once it passes.
701
+ * @throws {@link AssertionError} On timeout.
702
+ * @see
703
+ * - {@link waitUntil.isAtMost} : the opposite assertion.
704
+ * - {@link waitUntil.isAbove} : the more restrictive assertion.
705
+ */
706
+ isAtLeast: autoGuardSymbol,
707
+ /**
708
+ * Repeatedly calls a callback until its output is a number that is below the expectation
709
+ * (`actual < expected`). Once the callback output passes, it is returned. If the attempts
710
+ * time out, an error is thrown.
711
+ *
712
+ * Performs no type guarding.
713
+ *
714
+ * @example
715
+ *
716
+ * ```ts
717
+ * import {waitUntil} from '@augment-vir/assert';
718
+ *
719
+ * await waitUntil.isBelow(5, () => 10); // throws an error
720
+ * await waitUntil.isBelow(5, () => 5); // throws an error
721
+ * await waitUntil.isBelow(10, () => 5); // returns `5`
722
+ * ```
723
+ *
724
+ * @returns The callback output once it passes.
725
+ * @throws {@link AssertionError} On timeout.
726
+ * @see
727
+ * - {@link waitUntil.isAbove} : the opposite assertion.
728
+ * - {@link waitUntil.isAtMost} : the more lenient assertion.
729
+ */
730
+ isBelow: autoGuardSymbol,
731
+ /**
732
+ * Repeatedly calls a callback until its output is a number that is at most the expectation
733
+ * (`actual <= expected`). Once the callback output passes, it is returned. If the attempts
734
+ * time out, an error is thrown.
735
+ *
736
+ * Performs no type guarding.
737
+ *
738
+ * @example
739
+ *
740
+ * ```ts
741
+ * import {waitUntil} from '@augment-vir/assert';
742
+ *
743
+ * await waitUntil.isAtMost(5, () => 10); // throws an error
744
+ * await waitUntil.isAtMost(5, () => 5); // returns `5`
745
+ * await waitUntil.isAtMost(10, () => 5); // returns `5`
746
+ * ```
747
+ *
748
+ * @returns The callback output once it passes.
749
+ * @throws {@link AssertionError} On timeout.
750
+ * @see
751
+ * - {@link waitUntil.isAtLeast} : the opposite assertion.
752
+ * - {@link waitUntil.isBelow} : the more restrictive assertion.
753
+ */
754
+ isAtMost: autoGuardSymbol,
755
+ /**
756
+ * Repeatedly calls a callback until its output is a number that is
757
+ * [`NaN`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NaN).
758
+ * Once the callback output passes, it is returned. If the attempts time out, an error is
759
+ * thrown.
760
+ *
761
+ * Performs no type guarding.
762
+ *
763
+ * @example
764
+ *
765
+ * ```ts
766
+ * import {waitUntil} from '@augment-vir/assert';
767
+ *
768
+ * await waitUntil.isNaN(() => 10); // throws an error
769
+ * await waitUntil.isNaN(() => parseInt('invalid')); // returns `NaN`
770
+ * await waitUntil.isNaN(() => Infinity); // throws an error
771
+ * ```
772
+ *
773
+ * @returns The callback output once it passes.
774
+ * @throws {@link AssertionError} If the assertion fails.
775
+ * @see
776
+ * - {@link waitUntil.isNumber} : can be used as the opposite assertion.
777
+ */
778
+ isNaN: autoGuardSymbol,
779
+ /**
780
+ * Repeatedly calls a callback until its output is a number that is finite: meaning, not
781
+ * `NaN` and not `Infinity` or `-Infinity`. Once the callback output passes, it is returned.
782
+ * If the attempts time out, an error is thrown.
783
+ *
784
+ * Performs no type guarding.
785
+ *
786
+ * @example
787
+ *
788
+ * ```ts
789
+ * import {waitUntil} from '@augment-vir/assert';
790
+ *
791
+ * await waitUntil.isFinite(() => 10); // returns `10`
792
+ * await waitUntil.isFinite(() => parseInt('invalid')); // throws an error
793
+ * await waitUntil.isFinite(() => Infinity); // throws an error
794
+ * await waitUntil.isFinite(() => -Infinity); // throws an error
795
+ * ```
796
+ *
797
+ * @returns The callback output once it passes.
798
+ * @throws {@link AssertionError} If the assertion fails.
799
+ * @see
800
+ * - {@link waitUntil.isNaN} : an opposite assertion.
801
+ * - {@link waitUntil.isInfinite} : an opposite assertion.
802
+ */
803
+ isFinite: autoGuardSymbol,
804
+ /**
805
+ * Repeatedly calls a callback until its output is a number that is either `Infinity` or
806
+ * `-Infinity`. Once the callback output passes, it is returned. If the attempts time out,
807
+ * an error is thrown.
808
+ *
809
+ * Performs no type guarding.
810
+ *
811
+ * @example
812
+ *
813
+ * ```ts
814
+ * import {waitUntil} from '@augment-vir/assert';
815
+ *
816
+ * await waitUntil.isInfinite(() => 10); // throws an error
817
+ * await waitUntil.isInfinite(() => parseInt('invalid')); // throws an error
818
+ * await waitUntil.isInfinite(() => Infinity); // returns `Infinity`
819
+ * await waitUntil.isInfinite(() => -Infinity); // returns `-Infinity`
820
+ * ```
821
+ *
822
+ * @returns The callback output once it passes.
823
+ * @throws {@link AssertionError} If the assertion fails.
824
+ * @see
825
+ * - {@link waitUntil.isNaN} : an opposite assertion.
826
+ * - {@link waitUntil.isInfinite} : an opposite assertion.
827
+ */
828
+ isInfinite: autoGuardSymbol,
829
+ /**
830
+ * Repeatedly calls a callback until its output is a number that is within ±`delta` of the
831
+ * expectation. Once the callback output passes, it is returned. If the attempts time out,
832
+ * an error is thrown.
833
+ *
834
+ * Performs no type guarding.
835
+ *
836
+ * @example
837
+ *
838
+ * ```ts
839
+ * import {waitUntil} from '@augment-vir/assert';
840
+ *
841
+ * await waitUntil.isApproximately(8, 4, () => 10); // returns `10`
842
+ * await waitUntil.isApproximately(12, 4, () => 10); // returns `10`
843
+ * await waitUntil.isApproximately(8, 1, () => 10); // throws an error
844
+ * await waitUntil.isApproximately(12, 1, () => 10); // throws an error
845
+ * ```
846
+ *
847
+ * @returns The callback output once it passes.
848
+ * @throws {@link AssertionError} If the assertion fails.
849
+ * @see
850
+ * - {@link waitUntil.isNotApproximately} : the opposite assertion.
851
+ */
852
+ isApproximately: autoGuardSymbol,
853
+ /**
854
+ * Repeatedly calls a callback until its output is a number that is outside ±`delta` of the
855
+ * expectation. Once the callback output passes, it is returned. If the attempts time out,
856
+ * an error is thrown.
857
+ *
858
+ * Performs no type guarding.
859
+ *
860
+ * @example
861
+ *
862
+ * ```ts
863
+ * import {waitUntil} from '@augment-vir/assert';
864
+ *
865
+ * await waitUntil.isNotApproximately(8, 4, () => 10); // throws an error
866
+ * await waitUntil.isNotApproximately(12, 4, () => 10); // throws an error
867
+ * await waitUntil.isNotApproximately(8, 1, () => 10); // returns `10`
868
+ * await waitUntil.isNotApproximately(12, 1, () => 10); // returns `10`
869
+ * ```
870
+ *
871
+ * @returns The callback output once it passes.
872
+ * @throws {@link AssertionError} If the assertion fails.
873
+ * @see
874
+ * - {@link waitUntil.isApproximately} : the opposite assertion.
875
+ */
876
+ isNotApproximately: autoGuardSymbol,
877
+ },
60
878
  };