@augment-vir/assert 30.0.0 → 30.0.2

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 +21 -8
@@ -76,29 +76,561 @@ const assertions = {
76
76
  startsWithout,
77
77
  };
78
78
  export const boundaryGuards = {
79
- assertions,
80
- checkOverrides: {
79
+ assert: assertions,
80
+ check: {
81
+ /**
82
+ * Checks that a parent string or array ends with a specific child. This uses reference
83
+ * equality when the parent is an array.
84
+ *
85
+ * Performs no type guarding.
86
+ *
87
+ * @example
88
+ *
89
+ * ```ts
90
+ * import {check} from '@augment-vir/assert';
91
+ *
92
+ * check.endsWith('ab', 'b'); // returns `true`
93
+ * check.endsWith('ab', 'a'); // returns `false`
94
+ * check.endsWith(
95
+ * [
96
+ * 'a',
97
+ * 'b',
98
+ * ],
99
+ * 'b',
100
+ * ); // returns `true`
101
+ * check.endsWith(
102
+ * [
103
+ * 'a',
104
+ * 'b',
105
+ * ],
106
+ * 'a',
107
+ * ); // returns `false`
108
+ * ```
109
+ *
110
+ * @see
111
+ * - {@link check.endsWithout} : the opposite check.
112
+ * - {@link check.startsWith} : check on the other end.
113
+ */
81
114
  endsWith: autoGuard(),
115
+ /**
116
+ * Checks that a parent string or array does _not_ end with a specific child. This uses
117
+ * reference equality when the parent is an array.
118
+ *
119
+ * Performs no type guarding.
120
+ *
121
+ * @example
122
+ *
123
+ * ```ts
124
+ * import {check} from '@augment-vir/assert';
125
+ *
126
+ * check.endsWithout('ab', 'b'); // returns `false`
127
+ * check.endsWithout('ab', 'a'); // returns `true`
128
+ * check.endsWithout(
129
+ * [
130
+ * 'a',
131
+ * 'b',
132
+ * ],
133
+ * 'b',
134
+ * ); // returns `false`
135
+ * check.endsWithout(
136
+ * [
137
+ * 'a',
138
+ * 'b',
139
+ * ],
140
+ * 'a',
141
+ * ); // returns `true`
142
+ * ```
143
+ *
144
+ * @see
145
+ * - {@link check.endsWith} : the opposite check.
146
+ * - {@link check.startsWithout} : check on the other end.
147
+ */
82
148
  endsWithout: autoGuard(),
149
+ /**
150
+ * Checks that a parent string or array starts with a specific child. This uses reference
151
+ * equality when the parent is an array.
152
+ *
153
+ * Performs no type guarding.
154
+ *
155
+ * @example
156
+ *
157
+ * ```ts
158
+ * import {check} from '@augment-vir/assert';
159
+ *
160
+ * check.startsWith('ab', 'b'); // returns `false`
161
+ * check.startsWith('ab', 'a'); // returns `true`
162
+ * check.startsWith(
163
+ * [
164
+ * 'a',
165
+ * 'b',
166
+ * ],
167
+ * 'b',
168
+ * ); // returns `false`
169
+ * check.startsWith(
170
+ * [
171
+ * 'a',
172
+ * 'b',
173
+ * ],
174
+ * 'a',
175
+ * ); // returns `true`
176
+ * ```
177
+ *
178
+ * @see
179
+ * - {@link check.startsWithout} : the opposite check.
180
+ * - {@link check.endsWith} : check on the other end.
181
+ */
83
182
  startsWith: autoGuard(),
183
+ /**
184
+ * Checks that a parent string or array starts with a specific child. This uses reference
185
+ * equality when the parent is an array.
186
+ *
187
+ * Performs no type guarding.
188
+ *
189
+ * @example
190
+ *
191
+ * ```ts
192
+ * import {check} from '@augment-vir/assert';
193
+ *
194
+ * check.startsWith('ab', 'b'); // returns `false`
195
+ * check.startsWith('ab', 'a'); // returns `true`
196
+ * check.startsWith(
197
+ * [
198
+ * 'a',
199
+ * 'b',
200
+ * ],
201
+ * 'b',
202
+ * ); // returns `false`
203
+ * check.startsWith(
204
+ * [
205
+ * 'a',
206
+ * 'b',
207
+ * ],
208
+ * 'a',
209
+ * ); // returns `true`
210
+ * ```
211
+ *
212
+ * @see
213
+ * - {@link check.startsWithout} : the opposite check.
214
+ * - {@link check.endsWith} : check on the other end.
215
+ */
84
216
  startsWithout: autoGuard(),
85
217
  },
86
- assertWrapOverrides: {
218
+ assertWrap: {
219
+ /**
220
+ * Asserts that a parent string or array ends with a specific child. This uses reference
221
+ * equality when the parent is an array. Returns the parent if the assertion passes.
222
+ *
223
+ * Performs no type guarding.
224
+ *
225
+ * @example
226
+ *
227
+ * ```ts
228
+ * import {assertWrap} from '@augment-vir/assert';
229
+ *
230
+ * assertWrap.endsWith('ab', 'b'); // returns `'ab'`
231
+ * assertWrap.endsWith('ab', 'a'); // throws an error
232
+ * assertWrap.endsWith(
233
+ * [
234
+ * 'a',
235
+ * 'b',
236
+ * ],
237
+ * 'b',
238
+ * ); // returns `['a', 'b']`
239
+ * assertWrap.endsWith(
240
+ * [
241
+ * 'a',
242
+ * 'b',
243
+ * ],
244
+ * 'a',
245
+ * ); // throws an error
246
+ * ```
247
+ *
248
+ * @returns The parent value if it does end with the child.
249
+ * @throws {@link AssertionError} If the parent does not end with the child.
250
+ * @see
251
+ * - {@link assertWrap.endsWithout} : the opposite assertion.
252
+ * - {@link assertWrap.startsWith} : assertion on the other end.
253
+ */
87
254
  endsWith: autoGuard(),
255
+ /**
256
+ * Asserts that a parent string or array does _not_ end with a specific child. This uses
257
+ * reference equality when the parent is an array. Returns the parent if the assertion
258
+ * passes.
259
+ *
260
+ * Performs no type guarding.
261
+ *
262
+ * @example
263
+ *
264
+ * ```ts
265
+ * import {assertWrap} from '@augment-vir/assert';
266
+ *
267
+ * assertWrap.endsWithout('ab', 'b'); // throws an error
268
+ * assertWrap.endsWithout('ab', 'a'); // returns `'ab'`
269
+ * assertWrap.endsWithout(
270
+ * [
271
+ * 'a',
272
+ * 'b',
273
+ * ],
274
+ * 'b',
275
+ * ); // throws an error
276
+ * assertWrap.endsWithout(
277
+ * [
278
+ * 'a',
279
+ * 'b',
280
+ * ],
281
+ * 'a',
282
+ * ); // returns `['a', 'b']`
283
+ * ```
284
+ *
285
+ * @returns The parent value if it does not end with the child.
286
+ * @throws {@link AssertionError} If the parent ends with the child.
287
+ * @see
288
+ * - {@link assertWrap.endsWith} : the opposite assertion.
289
+ * - {@link assertWrap.startsWithout} : assertion on the other end.
290
+ */
88
291
  endsWithout: autoGuard(),
292
+ /**
293
+ * Checks that a parent string or array starts with a specific child. This uses reference
294
+ * equality when the parent is an array. Returns the parent 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.startsWith('ab', 'b'); // throws an error
304
+ * assertWrap.startsWith('ab', 'a'); // returns `'ab'`
305
+ * assertWrap.startsWith(
306
+ * [
307
+ * 'a',
308
+ * 'b',
309
+ * ],
310
+ * 'b',
311
+ * ); // throws an error
312
+ * assertWrap.startsWith(
313
+ * [
314
+ * 'a',
315
+ * 'b',
316
+ * ],
317
+ * 'a',
318
+ * ); // returns `['a', 'b']`
319
+ * ```
320
+ *
321
+ * @returns The parent value if it starts with the child.
322
+ * @throws {@link AssertionError} If the parent does not start with the child.
323
+ * @see
324
+ * - {@link assertWrap.startsWithout} : the opposite assertion.
325
+ * - {@link assertWrap.endsWith} : assertion on the other end.
326
+ */
89
327
  startsWith: autoGuard(),
328
+ /**
329
+ * Asserts that a parent string or array starts with a specific child. This uses reference
330
+ * equality when the parent is an array. Returns the parent if the assertion passes.
331
+ *
332
+ * Performs no type guarding.
333
+ *
334
+ * @example
335
+ *
336
+ * ```ts
337
+ * import {assertWrap} from '@augment-vir/assert';
338
+ *
339
+ * assertWrap.startsWith('ab', 'b'); // returns `'ab'`
340
+ * assertWrap.startsWith('ab', 'a'); // throws an error
341
+ * assertWrap.startsWith(
342
+ * [
343
+ * 'a',
344
+ * 'b',
345
+ * ],
346
+ * 'b',
347
+ * ); // returns `['a', 'b']`
348
+ * assertWrap.startsWith(
349
+ * [
350
+ * 'a',
351
+ * 'b',
352
+ * ],
353
+ * 'a',
354
+ * ); // throws an error
355
+ * ```
356
+ *
357
+ * @returns The parent value if it does not start with the child.
358
+ * @throws {@link AssertionError} If the parent does start with the child.
359
+ * @see
360
+ * - {@link assertWrap.startsWithout} : the opposite assertion.
361
+ * - {@link assertWrap.endsWith} : assertion on the other end.
362
+ */
90
363
  startsWithout: autoGuard(),
91
364
  },
92
- checkWrapOverrides: {
365
+ checkWrap: {
366
+ /**
367
+ * Checks that a parent string or array ends with a specific child. This uses reference
368
+ * equality when the parent is an array. Returns the value if the check passes, otherwise
369
+ * `undefined`.
370
+ *
371
+ * Performs no type guarding.
372
+ *
373
+ * @example
374
+ *
375
+ * ```ts
376
+ * import {checkWrap} from '@augment-vir/assert';
377
+ *
378
+ * checkWrap.endsWith('ab', 'b'); // returns `'ab'`
379
+ * checkWrap.endsWith('ab', 'a'); // returns `undefined`
380
+ * checkWrap.endsWith(
381
+ * [
382
+ * 'a',
383
+ * 'b',
384
+ * ],
385
+ * 'b',
386
+ * ); // returns `['a', 'b']`
387
+ * checkWrap.endsWith(
388
+ * [
389
+ * 'a',
390
+ * 'b',
391
+ * ],
392
+ * 'a',
393
+ * ); // returns `undefined`
394
+ * ```
395
+ *
396
+ * @returns The first value if the check passes, otherwise `undefined`.
397
+ * @see
398
+ * - {@link checkWrap.endsWithout} : the opposite check.
399
+ * - {@link checkWrap.startsWith} : check on the other end.
400
+ */
93
401
  endsWith: autoGuard(),
402
+ /**
403
+ * Checks that a parent string or array does _not_ end with a specific child. This uses
404
+ * reference equality when the parent is an array. Returns the value if the check passes,
405
+ * otherwise `undefined`.
406
+ *
407
+ * Performs no type guarding.
408
+ *
409
+ * @example
410
+ *
411
+ * ```ts
412
+ * import {checkWrap} from '@augment-vir/assert';
413
+ *
414
+ * checkWrap.endsWithout('ab', 'b'); // returns `undefined`
415
+ * checkWrap.endsWithout('ab', 'a'); // returns `'ab'`
416
+ * checkWrap.endsWithout(
417
+ * [
418
+ * 'a',
419
+ * 'b',
420
+ * ],
421
+ * 'b',
422
+ * ); // returns `undefined`
423
+ * checkWrap.endsWithout(
424
+ * [
425
+ * 'a',
426
+ * 'b',
427
+ * ],
428
+ * 'a',
429
+ * ); // returns `['a', 'b']`
430
+ * ```
431
+ *
432
+ * @returns The first value if the check passes, otherwise `undefined`.
433
+ * @see
434
+ * - {@link checkWrap.endsWith} : the opposite check.
435
+ * - {@link checkWrap.startsWithout} : check on the other end.
436
+ */
94
437
  endsWithout: autoGuard(),
438
+ /**
439
+ * Checks that a parent string or array starts with a specific child. This uses reference
440
+ * equality when the parent is an array. Returns the value if the check passes, otherwise
441
+ * `undefined`.
442
+ *
443
+ * Performs no type guarding.
444
+ *
445
+ * @example
446
+ *
447
+ * ```ts
448
+ * import {checkWrap} from '@augment-vir/assert';
449
+ *
450
+ * checkWrap.startsWith('ab', 'b'); // returns `undefined`
451
+ * checkWrap.startsWith('ab', 'a'); // returns `'ab'`
452
+ * checkWrap.startsWith(
453
+ * [
454
+ * 'a',
455
+ * 'b',
456
+ * ],
457
+ * 'b',
458
+ * ); // returns `undefined`
459
+ * checkWrap.startsWith(
460
+ * [
461
+ * 'a',
462
+ * 'b',
463
+ * ],
464
+ * 'a',
465
+ * ); // returns `['a', 'b']`
466
+ * ```
467
+ *
468
+ * @returns The first value if the check passes, otherwise `undefined`.
469
+ * @see
470
+ * - {@link checkWrap.startsWithout} : the opposite check.
471
+ * - {@link checkWrap.endsWith} : check on the other end.
472
+ */
95
473
  startsWith: autoGuard(),
474
+ /**
475
+ * Checks that a parent string or array starts with a specific child. This uses reference
476
+ * equality when the parent is an array. Returns the value if the check passes, otherwise
477
+ * `undefined`.
478
+ *
479
+ * Performs no type guarding.
480
+ *
481
+ * @example
482
+ *
483
+ * ```ts
484
+ * import {checkWrap} from '@augment-vir/assert';
485
+ *
486
+ * checkWrap.startsWith('ab', 'b'); // returns `undefined`
487
+ * checkWrap.startsWith('ab', 'a'); // returns `'ab'`
488
+ * checkWrap.startsWith(
489
+ * [
490
+ * 'a',
491
+ * 'b',
492
+ * ],
493
+ * 'b',
494
+ * ); // returns `undefined`
495
+ * checkWrap.startsWith(
496
+ * [
497
+ * 'a',
498
+ * 'b',
499
+ * ],
500
+ * 'a',
501
+ * ); // returns `['a', 'b']`
502
+ * ```
503
+ *
504
+ * @returns The first value if the check passes, otherwise `undefined`.
505
+ * @see
506
+ * - {@link checkWrap.startsWithout} : the opposite check.
507
+ * - {@link checkWrap.endsWith} : check on the other end.
508
+ */
96
509
  startsWithout: autoGuard(),
97
510
  },
98
- waitUntilOverrides: {
511
+ waitUntil: {
512
+ /**
513
+ * Repeatedly calls a callback until its output string or array ends with the first input
514
+ * child value. This uses reference equality when the parent is an array. Once the callback
515
+ * output passes, it is returned. If the attempts time out, an error is thrown.
516
+ *
517
+ * Performs no type guarding.
518
+ *
519
+ * @example
520
+ *
521
+ * ```ts
522
+ * import {waitUntil} from '@augment-vir/assert';
523
+ *
524
+ * await waitUntil.endsWith('b', () => 'ab'); // returns `'ab'`
525
+ * await waitUntil.endsWith('a', () => 'ab'); // throws an error
526
+ * await waitUntil.endsWith('b', () => [
527
+ * 'a',
528
+ * 'b',
529
+ * ]); // returns `['a', 'b']`
530
+ * await waitUntil.endsWith('a', () => [
531
+ * 'a',
532
+ * 'b',
533
+ * ]); // throws an error
534
+ * ```
535
+ *
536
+ * @returns The callback output once it passes.
537
+ * @throws {@link AssertionError} On timeout.
538
+ * @see
539
+ * - {@link waitUntil.endsWithout} : the opposite assertion.
540
+ * - {@link waitUntil.startsWith} : assertion on the other end.
541
+ */
99
542
  endsWith: autoGuard(),
543
+ /**
544
+ * Repeatedly calls a callback until its output string or array does not end with the first
545
+ * input child value. This uses reference equality when the parent is an array. Once the
546
+ * callback output passes, it is returned. If the attempts time out, an error is thrown.
547
+ *
548
+ * Performs no type guarding.
549
+ *
550
+ * @example
551
+ *
552
+ * ```ts
553
+ * import {waitUntil} from '@augment-vir/assert';
554
+ *
555
+ * await waitUntil.endsWith('b', () => 'ab'); // throws an error
556
+ * await waitUntil.endsWith('a', () => 'ab'); // returns `'ab'`
557
+ * await waitUntil.endsWith('b', () => [
558
+ * 'a',
559
+ * 'b',
560
+ * ]); // throws an error
561
+ * await waitUntil.endsWith('a', () => [
562
+ * 'a',
563
+ * 'b',
564
+ * ]); // returns `['a', 'b']`
565
+ * ```
566
+ *
567
+ * @returns The callback output once it passes.
568
+ * @throws {@link AssertionError} On timeout.
569
+ * @see
570
+ * - {@link waitUntil.endsWith} : the opposite assertion.
571
+ * - {@link waitUntil.startsWithout} : assertion on the other end.
572
+ */
100
573
  endsWithout: autoGuard(),
574
+ /**
575
+ * Repeatedly calls a callback until its output string or array starts with the first input
576
+ * child value. This uses reference equality when the parent is an array. Once the callback
577
+ * output passes, it is returned. If the attempts time out, an error is thrown.
578
+ *
579
+ * Performs no type guarding.
580
+ *
581
+ * @example
582
+ *
583
+ * ```ts
584
+ * import {waitUntil} from '@augment-vir/assert';
585
+ *
586
+ * await waitUntil.endsWith('b', () => 'ab'); // throws an error
587
+ * await waitUntil.endsWith('a', () => 'ab'); // returns `'ab'`
588
+ * await waitUntil.endsWith('b', () => [
589
+ * 'a',
590
+ * 'b',
591
+ * ]); // throws an error
592
+ * await waitUntil.endsWith('a', () => [
593
+ * 'a',
594
+ * 'b',
595
+ * ]); // returns `['a', 'b']`
596
+ * ```
597
+ *
598
+ * @returns The callback output once it passes.
599
+ * @throws {@link AssertionError} On timeout.
600
+ * @see
601
+ * - {@link waitUntil.startsWithout} : the opposite assertion.
602
+ * - {@link waitUntil.endsWith} : assertion on the other end.
603
+ */
101
604
  startsWith: autoGuard(),
605
+ /**
606
+ * Repeatedly calls a callback until its output string or array does not start with the
607
+ * first input child value. This uses reference equality when the parent is an array. Once
608
+ * the callback output passes, it is returned. If the attempts time out, an error is
609
+ * thrown.
610
+ *
611
+ * Performs no type guarding.
612
+ *
613
+ * @example
614
+ *
615
+ * ```ts
616
+ * await waitUntil.endsWith('b', () => 'ab'); // returns `'ab'`
617
+ * await waitUntil.endsWith('a', () => 'ab'); // throws an error
618
+ * await waitUntil.endsWith('b', () => [
619
+ * 'a',
620
+ * 'b',
621
+ * ]); // returns `['a', 'b']`
622
+ * await waitUntil.endsWith('a', () => [
623
+ * 'a',
624
+ * 'b',
625
+ * ]); // throws an error
626
+ * ```
627
+ *
628
+ * @returns The callback output once it passes.
629
+ * @throws {@link AssertionError} On timeout.
630
+ * @see
631
+ * - {@link waitUntil.startsWith} : the opposite assertion.
632
+ * - {@link waitUntil.endsWithout} : assertion on the other end.
633
+ */
102
634
  startsWithout: autoGuard(),
103
635
  },
104
636
  };