@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
@@ -1,6 +1,6 @@
1
1
  import { stringify } from '@augment-vir/core';
2
2
  import { AssertionError } from '../augments/assertion.error.js';
3
- import { autoGuard } from '../guard-types/guard-override.js';
3
+ import { autoGuard, autoGuardSymbol } from '../guard-types/guard-override.js';
4
4
  import { createWaitUntil } from '../guard-types/wait-until-function.js';
5
5
  function isPromiseLike(actual, failureMessage) {
6
6
  if (!(actual instanceof Promise) &&
@@ -41,29 +41,550 @@ const assertions = {
41
41
  isNotPromise,
42
42
  };
43
43
  export const promiseGuards = {
44
- assertions,
45
- checkOverrides: {
46
- isNotPromise: autoGuard(),
44
+ assert: assertions,
45
+ check: {
46
+ /**
47
+ * Checks that a value is a `PromiseLike`.
48
+ *
49
+ * `PromiseLike` is TypeScript built-in type that has a `.then` method and thus behaves like
50
+ * a promise. This is also referred to as a "thenable". This enables the use of third-party
51
+ * promise implementations that aren't instances of the built-in `Promise` class.
52
+ *
53
+ * Type guards the value.
54
+ *
55
+ * @example
56
+ *
57
+ * ```ts
58
+ * import {check} from '@augment-vir/assert';
59
+ *
60
+ * class CustomThenable {
61
+ * constructor(public value: any) {}
62
+ *
63
+ * then(onFulfilled?: AnyFunction, onRejected?: AnyFunction) {
64
+ * return new CustomThenable(
65
+ * onFulfilled ? onFulfilled(this.value) : this.value,
66
+ * );
67
+ * }
68
+ * }
69
+ *
70
+ * check.isPromiseLike(Promise.resolve(5)); // returns `true`
71
+ * check.isPromiseLike(new CustomThenable(5)); // returns `true`
72
+ * check.isPromiseLike(5); // returns `false`
73
+ * ```
74
+ *
75
+ * @see
76
+ * - {@link check.isNotPromiseLike} : the opposite check.
77
+ * - {@link check.isPromise} : the more precise check.
78
+ */
79
+ isPromiseLike: autoGuardSymbol,
80
+ /**
81
+ * Checks that a value is _not_ a `PromiseLike`.
82
+ *
83
+ * `PromiseLike` is TypeScript built-in type that has a `.then` method and thus behaves like
84
+ * a promise. This is also referred to as a "thenable". This enables the use of third-party
85
+ * promise implementations that aren't instances of the built-in `Promise` class.
86
+ *
87
+ * Type guards the value.
88
+ *
89
+ * @example
90
+ *
91
+ * ```ts
92
+ * import {check} from '@augment-vir/assert';
93
+ *
94
+ * class CustomThenable {
95
+ * constructor(public value: any) {}
96
+ *
97
+ * then(onFulfilled?: AnyFunction, onRejected?: AnyFunction) {
98
+ * return new CustomThenable(
99
+ * onFulfilled ? onFulfilled(this.value) : this.value,
100
+ * );
101
+ * }
102
+ * }
103
+ *
104
+ * check.isNotPromiseLike(Promise.resolve(5)); // returns `false`
105
+ * check.isNotPromiseLike(new CustomThenable(5)); // returns `false`
106
+ * check.isNotPromiseLike(5); // returns `true`
107
+ * ```
108
+ *
109
+ * @see
110
+ * - {@link check.isPromiseLike} : the opposite check.
111
+ * - {@link check.isNotPromise} : the more precise check.
112
+ */
47
113
  isNotPromiseLike: autoGuard(),
48
- },
49
- assertWrapOverrides: {
50
- isPromise: autoGuard(),
114
+ /**
115
+ * Checks that a value is a `Promise` instance.
116
+ *
117
+ * Type guards the value.
118
+ *
119
+ * @example
120
+ *
121
+ * ```ts
122
+ * import {check} from '@augment-vir/assert';
123
+ *
124
+ * class CustomThenable {
125
+ * constructor(public value: any) {}
126
+ *
127
+ * then(onFulfilled?: AnyFunction, onRejected?: AnyFunction) {
128
+ * return new CustomThenable(
129
+ * onFulfilled ? onFulfilled(this.value) : this.value,
130
+ * );
131
+ * }
132
+ * }
133
+ *
134
+ * check.isPromise(Promise.resolve(5)); // returns `true`
135
+ * check.isPromise(new CustomThenable(5)); // returns `false`
136
+ * check.isPromise(5); // returns `false`
137
+ * ```
138
+ *
139
+ * @see
140
+ * - {@link check.isNotPromise} : the opposite check.
141
+ * - {@link check.isPromiseLike} : the more lenient check.
142
+ */
143
+ isPromise: autoGuardSymbol,
144
+ /**
145
+ * Checks that a value is a _not_ `Promise` instance.
146
+ *
147
+ * Type guards the value.
148
+ *
149
+ * @example
150
+ *
151
+ * ```ts
152
+ * import {check} from '@augment-vir/assert';
153
+ *
154
+ * class CustomThenable {
155
+ * constructor(public value: any) {}
156
+ *
157
+ * then(onFulfilled?: AnyFunction, onRejected?: AnyFunction) {
158
+ * return new CustomThenable(
159
+ * onFulfilled ? onFulfilled(this.value) : this.value,
160
+ * );
161
+ * }
162
+ * }
163
+ *
164
+ * check.isNotPromise(Promise.resolve(5)); // returns `false`
165
+ * check.isNotPromise(new CustomThenable(5)); // returns `true`
166
+ * check.isNotPromise(5); // returns `true`
167
+ * ```
168
+ *
169
+ * @see
170
+ * - {@link check.isPromise} : the opposite check.
171
+ * - {@link check.isNotPromiseLike} : the more lenient check.
172
+ */
51
173
  isNotPromise: autoGuard(),
174
+ },
175
+ assertWrap: {
176
+ /**
177
+ * Asserts that a value is a `PromiseLike`. Returns the value if the assertion passes.
178
+ *
179
+ * `PromiseLike` is TypeScript built-in type that has a `.then` method and thus behaves like
180
+ * a promise. This is also referred to as a "thenable". This enables the use of third-party
181
+ * promise implementations that aren't instances of the built-in `Promise` class.
182
+ *
183
+ * Type guards the value.
184
+ *
185
+ * @example
186
+ *
187
+ * ```ts
188
+ * import {assertWrap} from '@augment-vir/assert';
189
+ *
190
+ * class CustomThenable {
191
+ * constructor(public value: any) {}
192
+ *
193
+ * then(onFulfilled?: AnyFunction, onRejected?: AnyFunction) {
194
+ * return new CustomThenable(
195
+ * onFulfilled ? onFulfilled(this.value) : this.value,
196
+ * );
197
+ * }
198
+ * }
199
+ *
200
+ * assertWrap.isPromiseLike(Promise.resolve(5)); // returns the `Promise` instance
201
+ * assertWrap.isPromiseLike(new CustomThenable(5)); // returns the `CustomThenable` instance
202
+ * assertWrap.isPromiseLike(5); // throws an error
203
+ * ```
204
+ *
205
+ * @returns The value if the assertion passes.
206
+ * @throws {@link AssertionError} If the assertion fails.
207
+ * @see
208
+ * - {@link assertWrap.isNotPromiseLike} : the opposite assertion.
209
+ * - {@link assertWrap.isPromise} : the more precise assertion.
210
+ */
52
211
  isPromiseLike: autoGuard(),
212
+ /**
213
+ * Asserts that a value is _not_ a `PromiseLike`. Returns the value if the assertion passes.
214
+ *
215
+ * `PromiseLike` is TypeScript built-in type that has a `.then` method and thus behaves like
216
+ * a promise. This is also referred to as a "thenable". This enables the use of third-party
217
+ * promise implementations that aren't instances of the built-in `Promise` class.
218
+ *
219
+ * Type guards the value.
220
+ *
221
+ * @example
222
+ *
223
+ * ```ts
224
+ * import {assertWrap} from '@augment-vir/assert';
225
+ *
226
+ * class CustomThenable {
227
+ * constructor(public value: any) {}
228
+ *
229
+ * then(onFulfilled?: AnyFunction, onRejected?: AnyFunction) {
230
+ * return new CustomThenable(
231
+ * onFulfilled ? onFulfilled(this.value) : this.value,
232
+ * );
233
+ * }
234
+ * }
235
+ *
236
+ * assertWrap.isNotPromiseLike(Promise.resolve(5)); // throws an error
237
+ * assertWrap.isNotPromiseLike(new CustomThenable(5)); // throws an error
238
+ * assertWrap.isNotPromiseLike(5); // returns `5`
239
+ * ```
240
+ *
241
+ * @returns The value if the assertion passes.
242
+ * @throws {@link AssertionError} If the assertion fails.
243
+ * @see
244
+ * - {@link assertWrap.isPromiseLike} : the opposite assertion.
245
+ * - {@link assertWrap.isNotPromise} : the more precise assertion.
246
+ */
53
247
  isNotPromiseLike: autoGuard(),
248
+ /**
249
+ * Asserts that a value is a `Promise` instance. Returns the value if the assertion passes.
250
+ *
251
+ * Type guards the value.
252
+ *
253
+ * @example
254
+ *
255
+ * ```ts
256
+ * import {assertWrap} from '@augment-vir/assert';
257
+ *
258
+ * class CustomThenable {
259
+ * constructor(public value: any) {}
260
+ *
261
+ * then(onFulfilled?: AnyFunction, onRejected?: AnyFunction) {
262
+ * return new CustomThenable(
263
+ * onFulfilled ? onFulfilled(this.value) : this.value,
264
+ * );
265
+ * }
266
+ * }
267
+ *
268
+ * assertWrap.isPromise(Promise.resolve(5)); // returns the `Promise` instance
269
+ * assertWrap.isPromise(new CustomThenable(5)); // throws an error
270
+ * assertWrap.isPromise(5); // throws an error
271
+ * ```
272
+ *
273
+ * @returns The value if the assertion passes.
274
+ * @throws {@link AssertionError} If the assertion fails.
275
+ * @see
276
+ * - {@link assertWrap.isNotPromise} : the opposite assertion.
277
+ * - {@link assertWrap.isPromiseLike} : the more lenient assertion.
278
+ */
279
+ isPromise: autoGuard(),
280
+ /**
281
+ * Asserts that a value is a _not_ `Promise` instance. Returns the value if the assertion
282
+ * passes.
283
+ *
284
+ * Type guards the value.
285
+ *
286
+ * @example
287
+ *
288
+ * ```ts
289
+ * import {assertWrap} from '@augment-vir/assert';
290
+ *
291
+ * class CustomThenable {
292
+ * constructor(public value: any) {}
293
+ *
294
+ * then(onFulfilled?: AnyFunction, onRejected?: AnyFunction) {
295
+ * return new CustomThenable(
296
+ * onFulfilled ? onFulfilled(this.value) : this.value,
297
+ * );
298
+ * }
299
+ * }
300
+ *
301
+ * assertWrap.isNotPromise(Promise.resolve(5)); // throws an error
302
+ * assertWrap.isNotPromise(new CustomThenable(5)); // returns the `CustomThenable` promise
303
+ * assertWrap.isNotPromise(5); // returns `5`
304
+ * ```
305
+ *
306
+ * @returns The value if the assertion passes.
307
+ * @throws {@link AssertionError} If the assertion fails.
308
+ * @see
309
+ * - {@link assertWrap.isPromise} : the opposite assertion.
310
+ * - {@link assertWrap.isNotPromiseLike} : the more lenient assertion.
311
+ */
312
+ isNotPromise: autoGuard(),
54
313
  },
55
- checkWrapOverrides: {
314
+ checkWrap: {
315
+ /**
316
+ * Checks that a value is a `PromiseLike`. Returns the value if the check passes, otherwise
317
+ * `undefined`.
318
+ *
319
+ * `PromiseLike` is TypeScript built-in type that has a `.then` method and thus behaves like
320
+ * a promise. This is also referred to as a "thenable". This enables the use of third-party
321
+ * promise implementations that aren't instances of the built-in `Promise` class.
322
+ *
323
+ * Type guards the value.
324
+ *
325
+ * @example
326
+ *
327
+ * ```ts
328
+ * import {checkWrap} from '@augment-vir/assert';
329
+ *
330
+ * class CustomThenable {
331
+ * constructor(public value: any) {}
332
+ *
333
+ * then(onFulfilled?: AnyFunction, onRejected?: AnyFunction) {
334
+ * return new CustomThenable(
335
+ * onFulfilled ? onFulfilled(this.value) : this.value,
336
+ * );
337
+ * }
338
+ * }
339
+ *
340
+ * checkWrap.isPromiseLike(Promise.resolve(5)); // returns `true`
341
+ * checkWrap.isPromiseLike(new CustomThenable(5)); // returns `true`
342
+ * checkWrap.isPromiseLike(5); // returns `false`
343
+ * ```
344
+ *
345
+ * @see
346
+ * - {@link checkWrap.isNotPromiseLike} : the opposite check.
347
+ * - {@link checkWrap.isPromise} : the more precise check.
348
+ */
56
349
  isNotPromise: autoGuard(),
350
+ /**
351
+ * Checks that a value is _not_ a `PromiseLike`. Returns the value if the check passes,
352
+ * otherwise `undefined`.
353
+ *
354
+ * `PromiseLike` is TypeScript built-in type that has a `.then` method and thus behaves like
355
+ * a promise. This is also referred to as a "thenable". This enables the use of third-party
356
+ * promise implementations that aren't instances of the built-in `Promise` class.
357
+ *
358
+ * Type guards the value.
359
+ *
360
+ * @example
361
+ *
362
+ * ```ts
363
+ * import {checkWrap} from '@augment-vir/assert';
364
+ *
365
+ * class CustomThenable {
366
+ * constructor(public value: any) {}
367
+ *
368
+ * then(onFulfilled?: AnyFunction, onRejected?: AnyFunction) {
369
+ * return new CustomThenable(
370
+ * onFulfilled ? onFulfilled(this.value) : this.value,
371
+ * );
372
+ * }
373
+ * }
374
+ *
375
+ * checkWrap.isNotPromiseLike(Promise.resolve(5)); // returns `false`
376
+ * checkWrap.isNotPromiseLike(new CustomThenable(5)); // returns `false`
377
+ * checkWrap.isNotPromiseLike(5); // returns `true`
378
+ * ```
379
+ *
380
+ * @see
381
+ * - {@link checkWrap.isPromiseLike} : the opposite check.
382
+ * - {@link checkWrap.isNotPromise} : the more precise check.
383
+ */
57
384
  isNotPromiseLike: autoGuard(),
385
+ /**
386
+ * Checks that a value is a `Promise` instance. Returns the value if the check passes,
387
+ * otherwise `undefined`.
388
+ *
389
+ * Type guards the value.
390
+ *
391
+ * @example
392
+ *
393
+ * ```ts
394
+ * import {checkWrap} from '@augment-vir/assert';
395
+ *
396
+ * class CustomThenable {
397
+ * constructor(public value: any) {}
398
+ *
399
+ * then(onFulfilled?: AnyFunction, onRejected?: AnyFunction) {
400
+ * return new CustomThenable(
401
+ * onFulfilled ? onFulfilled(this.value) : this.value,
402
+ * );
403
+ * }
404
+ * }
405
+ *
406
+ * checkWrap.isPromise(Promise.resolve(5)); // returns `true`
407
+ * checkWrap.isPromise(new CustomThenable(5)); // returns `false`
408
+ * checkWrap.isPromise(5); // returns `false`
409
+ * ```
410
+ *
411
+ * @see
412
+ * - {@link checkWrap.isNotPromise} : the opposite check.
413
+ * - {@link checkWrap.isPromiseLike} : the more lenient check.
414
+ */
415
+ isPromise: autoGuardSymbol,
416
+ /**
417
+ * Checks that a value is a _not_ `Promise` instance. Returns the value if the check passes,
418
+ * otherwise `undefined`.
419
+ *
420
+ * Type guards the value.
421
+ *
422
+ * @example
423
+ *
424
+ * ```ts
425
+ * import {checkWrap} from '@augment-vir/assert';
426
+ *
427
+ * class CustomThenable {
428
+ * constructor(public value: any) {}
429
+ *
430
+ * then(onFulfilled?: AnyFunction, onRejected?: AnyFunction) {
431
+ * return new CustomThenable(
432
+ * onFulfilled ? onFulfilled(this.value) : this.value,
433
+ * );
434
+ * }
435
+ * }
436
+ *
437
+ * checkWrap.isNotPromise(Promise.resolve(5)); // returns `false`
438
+ * checkWrap.isNotPromise(new CustomThenable(5)); // returns `true`
439
+ * checkWrap.isNotPromise(5); // returns `true`
440
+ * ```
441
+ *
442
+ * @see
443
+ * - {@link checkWrap.isPromise} : the opposite check.
444
+ * - {@link checkWrap.isNotPromiseLike} : the more lenient check.
445
+ */
446
+ isPromiseLike: autoGuardSymbol,
58
447
  },
59
- /**
60
- * These overrides must explicitly use `createWaitUntil` so they can pass in `true` for the
61
- * second parameter, `requireSynchronousResult`.
62
- */
63
- waitUntilOverrides: {
64
- isPromise: createWaitUntil(isPromise, true),
65
- isNotPromise: createWaitUntil(isNotPromise, true),
448
+ waitUntil: {
449
+ /**
450
+ * Repeatedly calls a callback until its output is a `PromiseLike`. Once the callback output
451
+ * passes, it is returned. If the attempts time out, an error is thrown.
452
+ *
453
+ * `PromiseLike` is TypeScript built-in type that has a `.then` method and thus behaves like
454
+ * a promise. This is also referred to as a "thenable". This enables the use of third-party
455
+ * promise implementations that aren't instances of the built-in `Promise` class.
456
+ *
457
+ * Type guards the value.
458
+ *
459
+ * @example
460
+ *
461
+ * ```ts
462
+ * import {waitUntil} from '@augment-vir/assert';
463
+ *
464
+ * class CustomThenable {
465
+ * constructor(public value: any) {}
466
+ *
467
+ * then(onFulfilled?: AnyFunction, onRejected?: AnyFunction) {
468
+ * return new CustomThenable(
469
+ * onFulfilled ? onFulfilled(this.value) : this.value,
470
+ * );
471
+ * }
472
+ * }
473
+ *
474
+ * await waitUntil.isPromiseLike(() => Promise.resolve(5)); // returns the resolved `5`
475
+ * await waitUntil.isPromiseLike(() => new CustomThenable(5)); // returns the resolved `5`
476
+ * await waitUntil.isPromiseLike(() => 5); // throws an error
477
+ * ```
478
+ *
479
+ * @returns The callback output once it passes.
480
+ * @throws {@link AssertionError} If the assertion fails.
481
+ * @see
482
+ * - {@link waitUntil.isNotPromiseLike} : the opposite assertion.
483
+ * - {@link waitUntil.isPromise} : the more precise assertion.
484
+ */
66
485
  isPromiseLike: createWaitUntil(isPromiseLike, true),
486
+ /**
487
+ * Repeatedly calls a callback until its output is _not_ a `PromiseLike`. Once the callback
488
+ * output passes, it is returned. If the attempts time out, an error is thrown.
489
+ *
490
+ * `PromiseLike` is TypeScript built-in type that has a `.then` method and thus behaves like
491
+ * a promise. This is also referred to as a "thenable". This enables the use of third-party
492
+ * promise implementations that aren't instances of the built-in `Promise` class.
493
+ *
494
+ * Type guards the value.
495
+ *
496
+ * @example
497
+ *
498
+ * ```ts
499
+ * import {waitUntil} from '@augment-vir/assert';
500
+ *
501
+ * class CustomThenable {
502
+ * constructor(public value: any) {}
503
+ *
504
+ * then(onFulfilled?: AnyFunction, onRejected?: AnyFunction) {
505
+ * return new CustomThenable(
506
+ * onFulfilled ? onFulfilled(this.value) : this.value,
507
+ * );
508
+ * }
509
+ * }
510
+ *
511
+ * await waitUntil.isNotPromiseLike(() => Promise.resolve(5)); // throws an error
512
+ * await waitUntil.isNotPromiseLike(() => new CustomThenable(5)); // throws an error
513
+ * await waitUntil.isNotPromiseLike(() => 5); // returns `5`
514
+ * ```
515
+ *
516
+ * @returns The callback output once it passes.
517
+ * @throws {@link AssertionError} If the assertion fails.
518
+ * @see
519
+ * - {@link waitUntil.isPromiseLike} : the opposite assertion.
520
+ * - {@link waitUntil.isNotPromise} : the more precise assertion.
521
+ */
67
522
  isNotPromiseLike: createWaitUntil(isNotPromiseLike, true),
523
+ /**
524
+ * Repeatedly calls a callback until its output is a `Promise` instance. Once the callback
525
+ * output passes, it is returned. If the attempts time out, an error is thrown.
526
+ *
527
+ * Type guards the value.
528
+ *
529
+ * @example
530
+ *
531
+ * ```ts
532
+ * import {waitUntil} from '@augment-vir/assert';
533
+ *
534
+ * class CustomThenable {
535
+ * constructor(public value: any) {}
536
+ *
537
+ * then(onFulfilled?: AnyFunction, onRejected?: AnyFunction) {
538
+ * return new CustomThenable(
539
+ * onFulfilled ? onFulfilled(this.value) : this.value,
540
+ * );
541
+ * }
542
+ * }
543
+ *
544
+ * await waitUntil.isPromise(() => Promise.resolve(5)); // returns the resolved `5`
545
+ * await waitUntil.isPromise(() => new CustomThenable(5)); // throws an error
546
+ * await waitUntil.isPromise(() => 5); // throws an error
547
+ * ```
548
+ *
549
+ * @returns The callback output once it passes.
550
+ * @throws {@link AssertionError} If the assertion fails.
551
+ * @see
552
+ * - {@link waitUntil.isNotPromise} : the opposite assertion.
553
+ * - {@link waitUntil.isPromiseLike} : the more lenient assertion.
554
+ */
555
+ isPromise: createWaitUntil(isPromise, true),
556
+ /**
557
+ * Repeatedly calls a callback until its output is a _not_ `Promise` instance. Once the
558
+ * callback output passes, it is returned. If the attempts time out, an error is thrown.
559
+ *
560
+ * Type guards the value.
561
+ *
562
+ * @example
563
+ *
564
+ * ```ts
565
+ * import {waitUntil} from '@augment-vir/assert';
566
+ *
567
+ * class CustomThenable {
568
+ * constructor(public value: any) {}
569
+ *
570
+ * then(onFulfilled?: AnyFunction, onRejected?: AnyFunction) {
571
+ * return new CustomThenable(
572
+ * onFulfilled ? onFulfilled(this.value) : this.value,
573
+ * );
574
+ * }
575
+ * }
576
+ *
577
+ * await waitUntil.isNotPromise(() => Promise.resolve(5)); // throws an error
578
+ * await waitUntil.isNotPromise(() => new CustomThenable(5)); // returns the resolved `5`
579
+ * await waitUntil.isNotPromise(() => 5); // returns the resolved `5`
580
+ * ```
581
+ *
582
+ * @returns The callback output once it passes.
583
+ * @throws {@link AssertionError} If the assertion fails.
584
+ * @see
585
+ * - {@link waitUntil.isPromise} : the opposite assertion.
586
+ * - {@link waitUntil.isNotPromiseLike} : the more lenient assertion.
587
+ */
588
+ isNotPromise: createWaitUntil(isNotPromise, true),
68
589
  },
69
590
  };