@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
@@ -48,21 +48,325 @@ const assertions = {
48
48
  isLengthExactly,
49
49
  };
50
50
  export const lengthGuards = {
51
- assertions,
52
- checkOverrides: {
51
+ assert: assertions,
52
+ check: {
53
+ /**
54
+ * Checks that an array or string has at least the given length.
55
+ *
56
+ * Type guards an array into an {@link AtLeastTuple}. Performs no type guarding on a string.
57
+ *
58
+ * @example
59
+ *
60
+ * ```ts
61
+ * import {check} from '@augment-vir/assert';
62
+ *
63
+ * check.isLengthAtLeast(
64
+ * [
65
+ * 'a',
66
+ * 'b',
67
+ * 'c',
68
+ * ],
69
+ * 2,
70
+ * ); // returns `true`
71
+ * check.isLengthAtLeast(
72
+ * [
73
+ * 'a',
74
+ * 'b',
75
+ * 'c',
76
+ * ],
77
+ * 3,
78
+ * ); // returns `true`
79
+ * check.isLengthAtLeast(
80
+ * [
81
+ * 'a',
82
+ * 'b',
83
+ * ],
84
+ * 3,
85
+ * ); // returns `false`
86
+ * ```
87
+ *
88
+ * @see
89
+ * - {@link check.isLengthExactly} : the more exact check.
90
+ */
53
91
  isLengthAtLeast: autoGuard(),
92
+ /**
93
+ * Checks that an array or string has exactly the given length.
94
+ *
95
+ * Type guards an array into a {@link Tuple}. Performs no type guarding on a string.
96
+ *
97
+ * @example
98
+ *
99
+ * ```ts
100
+ * import {check} from '@augment-vir/assert';
101
+ *
102
+ * check.isLengthExactly(
103
+ * [
104
+ * 'a',
105
+ * 'b',
106
+ * 'c',
107
+ * ],
108
+ * 2,
109
+ * ); // fails
110
+ * check.isLengthExactly(
111
+ * [
112
+ * 'a',
113
+ * 'b',
114
+ * 'c',
115
+ * ],
116
+ * 3,
117
+ * ); // passes
118
+ * check.isLengthExactly(
119
+ * [
120
+ * 'a',
121
+ * 'b',
122
+ * ],
123
+ * 3,
124
+ * ); // fails
125
+ * ```
126
+ *
127
+ * @see
128
+ * - {@link check.isLengthAtLeast} : the more flexible check.
129
+ */
54
130
  isLengthExactly: autoGuard(),
55
131
  },
56
- assertWrapOverrides: {
132
+ assertWrap: {
133
+ /**
134
+ * Asserts that an array or string has at least the given length. Returns the value if the
135
+ * assertion passes.
136
+ *
137
+ * Type guards an array into an {@link AtLeastTuple}. Performs no type guarding on a string.
138
+ *
139
+ * @example
140
+ *
141
+ * ```ts
142
+ * import {assertWrap} from '@augment-vir/assert';
143
+ *
144
+ * assertWrap.isLengthAtLeast(
145
+ * [
146
+ * 'a',
147
+ * 'b',
148
+ * 'c',
149
+ * ],
150
+ * 2,
151
+ * ); // returns `['a', 'b', 'c']`
152
+ * assertWrap.isLengthAtLeast(
153
+ * [
154
+ * 'a',
155
+ * 'b',
156
+ * 'c',
157
+ * ],
158
+ * 3,
159
+ * ); // returns `['a', 'b', 'c']`
160
+ * assertWrap.isLengthAtLeast(
161
+ * [
162
+ * 'a',
163
+ * 'b',
164
+ * ],
165
+ * 3,
166
+ * ); // throws an error
167
+ * ```
168
+ *
169
+ * @returns The value if it has at least the given length.
170
+ * @throws {@link AssertionError} If the value is less than the given length.
171
+ * @see
172
+ * - {@link assertWrap.isLengthExactly} : the more exact assertion.
173
+ */
57
174
  isLengthAtLeast: autoGuard(),
175
+ /**
176
+ * Asserts that an array or string has exactly the given length. Returns the value if the
177
+ * assertion passes.
178
+ *
179
+ * Type guards an array into a {@link Tuple}. Performs no type guarding on a string.
180
+ *
181
+ * @example
182
+ *
183
+ * ```ts
184
+ * import {assertWrap} from '@augment-vir/assert';
185
+ *
186
+ * assertWrap.isLengthExactly(
187
+ * [
188
+ * 'a',
189
+ * 'b',
190
+ * 'c',
191
+ * ],
192
+ * 2,
193
+ * ); // throws an error
194
+ * assertWrap.isLengthExactly(
195
+ * [
196
+ * 'a',
197
+ * 'b',
198
+ * 'c',
199
+ * ],
200
+ * 3,
201
+ * ); // returns `['a', 'b', 'c']`
202
+ * assertWrap.isLengthExactly(
203
+ * [
204
+ * 'a',
205
+ * 'b',
206
+ * ],
207
+ * 3,
208
+ * ); // throws an error
209
+ * ```
210
+ *
211
+ * @returns The value if it has exactly the given length.
212
+ * @throws {@link AssertionError} If the value is not exactly the given length.
213
+ * @see
214
+ * - {@link assertWrap.isLengthAtLeast} : the more flexible assertion.
215
+ */
58
216
  isLengthExactly: autoGuard(),
59
217
  },
60
- checkWrapOverrides: {
218
+ checkWrap: {
219
+ /**
220
+ * Checks that an array or string has at least the given length. Returns the value if the
221
+ * check passes, otherwise `undefined`.
222
+ *
223
+ * Type guards an array into an {@link AtLeastTuple}. Performs no type guarding on a string.
224
+ *
225
+ * @example
226
+ *
227
+ * ```ts
228
+ * import {checkWrap} from '@augment-vir/assert';
229
+ *
230
+ * checkWrap.isLengthAtLeast(
231
+ * [
232
+ * 'a',
233
+ * 'b',
234
+ * 'c',
235
+ * ],
236
+ * 2,
237
+ * ); // returns `['a', 'b', 'c']`
238
+ * checkWrap.isLengthAtLeast(
239
+ * [
240
+ * 'a',
241
+ * 'b',
242
+ * 'c',
243
+ * ],
244
+ * 3,
245
+ * ); // returns `['a', 'b', 'c']`
246
+ * checkWrap.isLengthAtLeast(
247
+ * [
248
+ * 'a',
249
+ * 'b',
250
+ * ],
251
+ * 3,
252
+ * ); // returns `undefined`
253
+ * ```
254
+ *
255
+ * @returns The value if the check passes, otherwise `undefined`.
256
+ * @see
257
+ * - {@link checkWrap.isLengthExactly} : the more exact check.
258
+ */
61
259
  isLengthAtLeast: autoGuard(),
260
+ /**
261
+ * Checks that an array or string has exactly the given length. Returns the value if the
262
+ * check passes, otherwise `undefined`.
263
+ *
264
+ * Type guards an array into a {@link Tuple}. Performs no type guarding on a string.
265
+ *
266
+ * @example
267
+ *
268
+ * ```ts
269
+ * import {checkWrap} from '@augment-vir/assert';
270
+ *
271
+ * checkWrap.isLengthExactly(
272
+ * [
273
+ * 'a',
274
+ * 'b',
275
+ * 'c',
276
+ * ],
277
+ * 2,
278
+ * ); // returns `undefined`
279
+ * checkWrap.isLengthExactly(
280
+ * [
281
+ * 'a',
282
+ * 'b',
283
+ * 'c',
284
+ * ],
285
+ * 3,
286
+ * ); // returns `['a', 'b', 'c']`
287
+ * checkWrap.isLengthExactly(
288
+ * [
289
+ * 'a',
290
+ * 'b',
291
+ * ],
292
+ * 3,
293
+ * ); // returns `undefined`
294
+ * ```
295
+ *
296
+ * @returns The value if the check passes, otherwise `undefined`.
297
+ * @see
298
+ * - {@link checkWrap.isLengthAtLeast} : the more flexible check.
299
+ */
62
300
  isLengthExactly: autoGuard(),
63
301
  },
64
- waitUntilOverrides: {
302
+ waitUntil: {
303
+ /**
304
+ * Repeatedly calls a callback until its output is an array or string that has at least the
305
+ * given length. Once the callback output passes, it is returned. If the attempts time out,
306
+ * an error is thrown.
307
+ *
308
+ * Type guards an array into an {@link AtLeastTuple}. Performs no type guarding on a string.
309
+ *
310
+ * @example
311
+ *
312
+ * ```ts
313
+ * import {waitUntil} from '@augment-vir/assert';
314
+ *
315
+ * await waitUntil.isLengthAtLeast(2, () => [
316
+ * 'a',
317
+ * 'b',
318
+ * 'c',
319
+ * ]); // returns `['a', 'b', 'c']`
320
+ * await waitUntil.isLengthAtLeast(3, () => [
321
+ * 'a',
322
+ * 'b',
323
+ * 'c',
324
+ * ]); // returns `['a', 'b', 'c']`
325
+ * await waitUntil.isLengthAtLeast(3, () => [
326
+ * 'a',
327
+ * 'b',
328
+ * ]); // throws an error
329
+ * ```
330
+ *
331
+ * @returns The callback output once it passes.
332
+ * @throws {@link AssertionError} On timeout.
333
+ * @see
334
+ * - {@link waitUntil.isLengthExactly} : the more exact assertion.
335
+ */
65
336
  isLengthAtLeast: autoGuard(),
337
+ /**
338
+ * Repeatedly calls a callback until its output is an array or string that has exactly the
339
+ * given length. Once the callback output passes, it is returned. If the attempts time out,
340
+ * an error is thrown.
341
+ *
342
+ * Type guards an array into a {@link Tuple}. Performs no type guarding on a string.
343
+ *
344
+ * @example
345
+ *
346
+ * ```ts
347
+ * import {waitUntil} from '@augment-vir/assert';
348
+ *
349
+ * await waitUntil.isLengthAtLeast(2, () => [
350
+ * 'a',
351
+ * 'b',
352
+ * 'c',
353
+ * ]); // throws an error
354
+ * await waitUntil.isLengthAtLeast(3, () => [
355
+ * 'a',
356
+ * 'b',
357
+ * 'c',
358
+ * ]); // returns `['a', 'b', 'c']`
359
+ * await waitUntil.isLengthAtLeast(3, () => [
360
+ * 'a',
361
+ * 'b',
362
+ * ]); // throws an error
363
+ * ```
364
+ *
365
+ * @returns The callback output once it passes.
366
+ * @throws {@link AssertionError} On timeout.
367
+ * @see
368
+ * - {@link waitUntil.isLengthAtLeast} : the more flexible assertion.
369
+ */
66
370
  isLengthExactly: autoGuard(),
67
371
  },
68
372
  };
@@ -1,4 +1,5 @@
1
1
  import { MaybePromise } from '@augment-vir/core';
2
+ import { autoGuardSymbol } from '../guard-types/guard-override.js';
2
3
  import { WaitUntilOptions } from '../guard-types/wait-until-function.js';
3
4
  declare function isDefined<const Actual>(
4
5
  /** The value to check. */
@@ -11,33 +12,194 @@ input: unknown,
11
12
  /** Message to include in error message if this assertion fails. */
12
13
  failureMessage?: string | undefined): asserts input is null | undefined;
13
14
  export declare const nullishGuards: {
14
- assertions: {
15
+ assert: {
15
16
  /**
16
- * Checks that a value is defined (not `null` and not `undefined`).
17
+ * Asserts that a value is defined (not `null` and not `undefined`).
17
18
  *
18
19
  * Type guards the value.
20
+ *
21
+ * @example
22
+ *
23
+ * ```ts
24
+ * import {assert} from '@augment-vir/assert';
25
+ *
26
+ * assert.isDefined(0); // passes
27
+ * assert.isDefined(''); // passes
28
+ * assert.isDefined(null); // fails
29
+ * assert.isDefined(undefined); // fails
30
+ * ```
31
+ *
32
+ * @throws {@link AssertionError} If the assertion fails.
33
+ * @see
34
+ * - {@link assert.isNullish} : the opposite assertion.
19
35
  */
20
36
  isDefined: typeof isDefined;
21
37
  /**
22
- * Checks that a value is nullish (`null` or `undefined`).
38
+ * Asserts that a value is nullish (`null` or `undefined`).
23
39
  *
24
40
  * Type guards the value.
41
+ *
42
+ * @example
43
+ *
44
+ * ```ts
45
+ * import {assert} from '@augment-vir/assert';
46
+ *
47
+ * assert.isNullish(0); // fails
48
+ * assert.isNullish(''); // fails
49
+ * assert.isNullish(null); // passes
50
+ * assert.isNullish(undefined); // passes
51
+ * ```
52
+ *
53
+ * @throws {@link AssertionError} If the assertion fails.
54
+ * @see
55
+ * - {@link assert.isDefined} : the opposite assertion.
25
56
  */
26
57
  isNullish: typeof isNullish;
27
58
  };
28
- checkOverrides: {
59
+ check: {
60
+ /**
61
+ * Checks that a value is defined (not `null` and not `undefined`).
62
+ *
63
+ * Type guards the value.
64
+ *
65
+ * @example
66
+ *
67
+ * ```ts
68
+ * import {check} from '@augment-vir/assert';
69
+ *
70
+ * check.isDefined(0); // returns `true`
71
+ * check.isDefined(''); // returns `true`
72
+ * check.isDefined(null); // returns `false`
73
+ * check.isDefined(undefined); // returns `false`
74
+ * ```
75
+ *
76
+ * @see
77
+ * - {@link check.isNullish} : the opposite check.
78
+ */
29
79
  isDefined: <Actual>(input: Actual) => input is Exclude<Actual, undefined | null>;
80
+ /**
81
+ * Checks that a value is nullish (`null` or `undefined`).
82
+ *
83
+ * Type guards the value.
84
+ *
85
+ * @example
86
+ *
87
+ * ```ts
88
+ * import {check} from '@augment-vir/assert';
89
+ *
90
+ * check.isNullish(0); // returns `false`
91
+ * check.isNullish(''); // returns `false`
92
+ * check.isNullish(null); // returns `true`
93
+ * check.isNullish(undefined); // returns `true`
94
+ * ```
95
+ *
96
+ * @see
97
+ * - {@link check.isDefined} : the opposite check.
98
+ */
99
+ isNullish: typeof autoGuardSymbol;
30
100
  };
31
- assertWrapOverrides: {
101
+ assertWrap: {
102
+ /**
103
+ * Asserts that a value is defined (not `null` and not `undefined`). Returns the value if
104
+ * the assertion passes.
105
+ *
106
+ * Type guards the value.
107
+ *
108
+ * @example
109
+ *
110
+ * ```ts
111
+ * import {assertWrap} from '@augment-vir/assert';
112
+ *
113
+ * assertWrap.isDefined(0); // returns `0`
114
+ * assertWrap.isDefined(''); // returns `''`
115
+ * assertWrap.isDefined(null); // fails
116
+ * assertWrap.isDefined(undefined); // fails
117
+ * ```
118
+ *
119
+ * @returns The value if the assertion passes.
120
+ * @throws {@link AssertionError} If the assertion fails.
121
+ * @see
122
+ * - {@link assertWrap.isNullish} : the opposite assertion.
123
+ */
32
124
  isDefined: <Actual>(input: Actual, failureMessage?: string | undefined) => Exclude<Actual, undefined | null>;
125
+ /**
126
+ * Asserts that a value is nullish (`null` or `undefined`). Returns the value if the
127
+ * assertion passes.
128
+ *
129
+ * Type guards the value.
130
+ *
131
+ * @example
132
+ *
133
+ * ```ts
134
+ * import {assertWrap} from '@augment-vir/assert';
135
+ *
136
+ * assertWrap.isNullish(0); // fails
137
+ * assertWrap.isNullish(''); // fails
138
+ * assertWrap.isNullish(null); // returns `null`
139
+ * assertWrap.isNullish(undefined); // returns `undefined`
140
+ * ```
141
+ *
142
+ * @returns The value if the assertion passes.
143
+ * @throws {@link AssertionError} If the assertion fails.
144
+ * @see
145
+ * - {@link assertWrap.isDefined} : the opposite assertion.
146
+ */
147
+ isNullish: typeof autoGuardSymbol;
33
148
  };
34
149
  /** Nullish checks don't make any sense on `checkWrap`. */
35
- checkWrapOverrides: {
150
+ checkWrap: {
36
151
  isDefined: undefined;
37
152
  isNullish: undefined;
38
153
  };
39
- waitUntilOverrides: {
154
+ waitUntil: {
155
+ /**
156
+ * Repeatedly calls a callback until its output is a value that is defined (not `null` and
157
+ * not `undefined`). Once the callback output passes, it is returned. If the attempts time
158
+ * out, an error is thrown.
159
+ *
160
+ * Type guards the value.
161
+ *
162
+ * @example
163
+ *
164
+ * ```ts
165
+ * import {waitUntil} from '@augment-vir/assert';
166
+ *
167
+ * await waitUntil.isDefined(() => 0); // returns `0`
168
+ * await waitUntil.isDefined(() => ''); // returns `''`
169
+ * await waitUntil.isDefined(() => null); // throws an error
170
+ * await waitUntil.isDefined(() => undefined); // throws an error
171
+ * ```
172
+ *
173
+ * @returns The callback output once it passes.
174
+ * @throws {@link AssertionError} On timeout.
175
+ * @see
176
+ * - {@link waitUntil.isNullish} : the opposite assertion.
177
+ */
40
178
  isDefined: <Actual>(callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, undefined | null>>;
179
+ /**
180
+ * Repeatedly calls a callback until its output is a value that is nullish (`null` or
181
+ * `undefined`). Once the callback output passes, it is returned. If the attempts time out,
182
+ * an error is thrown.
183
+ *
184
+ * Type guards the value.
185
+ *
186
+ * @example
187
+ *
188
+ * ```ts
189
+ * import {waitUntil} from '@augment-vir/assert';
190
+ *
191
+ * await waitUntil.isNullish(() => 0); // throws an error
192
+ * await waitUntil.isNullish(() => ''); // throws an error
193
+ * await waitUntil.isNullish(() => null); // returns `null`
194
+ * await waitUntil.isNullish(() => undefined); // returns `undefined`
195
+ * ```
196
+ *
197
+ * @returns The callback output once it passes.
198
+ * @throws {@link AssertionError} On timeout.
199
+ * @see
200
+ * - {@link waitUntil.isDefined} : the opposite assertion.
201
+ */
202
+ isNullish: typeof autoGuardSymbol;
41
203
  };
42
204
  };
43
205
  export {};
@@ -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
  function isDefined(
5
5
  /** The value to check. */
6
6
  input,
@@ -24,19 +24,150 @@ const assertions = {
24
24
  isNullish,
25
25
  };
26
26
  export const nullishGuards = {
27
- assertions: assertions,
28
- checkOverrides: {
27
+ assert: assertions,
28
+ check: {
29
+ /**
30
+ * Checks that a value is defined (not `null` and not `undefined`).
31
+ *
32
+ * Type guards the value.
33
+ *
34
+ * @example
35
+ *
36
+ * ```ts
37
+ * import {check} from '@augment-vir/assert';
38
+ *
39
+ * check.isDefined(0); // returns `true`
40
+ * check.isDefined(''); // returns `true`
41
+ * check.isDefined(null); // returns `false`
42
+ * check.isDefined(undefined); // returns `false`
43
+ * ```
44
+ *
45
+ * @see
46
+ * - {@link check.isNullish} : the opposite check.
47
+ */
29
48
  isDefined: autoGuard(),
49
+ /**
50
+ * Checks that a value is nullish (`null` or `undefined`).
51
+ *
52
+ * Type guards the value.
53
+ *
54
+ * @example
55
+ *
56
+ * ```ts
57
+ * import {check} from '@augment-vir/assert';
58
+ *
59
+ * check.isNullish(0); // returns `false`
60
+ * check.isNullish(''); // returns `false`
61
+ * check.isNullish(null); // returns `true`
62
+ * check.isNullish(undefined); // returns `true`
63
+ * ```
64
+ *
65
+ * @see
66
+ * - {@link check.isDefined} : the opposite check.
67
+ */
68
+ isNullish: autoGuardSymbol,
30
69
  },
31
- assertWrapOverrides: {
70
+ assertWrap: {
71
+ /**
72
+ * Asserts that a value is defined (not `null` and not `undefined`). Returns the value if
73
+ * the assertion passes.
74
+ *
75
+ * Type guards the value.
76
+ *
77
+ * @example
78
+ *
79
+ * ```ts
80
+ * import {assertWrap} from '@augment-vir/assert';
81
+ *
82
+ * assertWrap.isDefined(0); // returns `0`
83
+ * assertWrap.isDefined(''); // returns `''`
84
+ * assertWrap.isDefined(null); // fails
85
+ * assertWrap.isDefined(undefined); // fails
86
+ * ```
87
+ *
88
+ * @returns The value if the assertion passes.
89
+ * @throws {@link AssertionError} If the assertion fails.
90
+ * @see
91
+ * - {@link assertWrap.isNullish} : the opposite assertion.
92
+ */
32
93
  isDefined: autoGuard(),
94
+ /**
95
+ * Asserts that a value is nullish (`null` or `undefined`). Returns the value if the
96
+ * assertion passes.
97
+ *
98
+ * Type guards the value.
99
+ *
100
+ * @example
101
+ *
102
+ * ```ts
103
+ * import {assertWrap} from '@augment-vir/assert';
104
+ *
105
+ * assertWrap.isNullish(0); // fails
106
+ * assertWrap.isNullish(''); // fails
107
+ * assertWrap.isNullish(null); // returns `null`
108
+ * assertWrap.isNullish(undefined); // returns `undefined`
109
+ * ```
110
+ *
111
+ * @returns The value if the assertion passes.
112
+ * @throws {@link AssertionError} If the assertion fails.
113
+ * @see
114
+ * - {@link assertWrap.isDefined} : the opposite assertion.
115
+ */
116
+ isNullish: autoGuardSymbol,
33
117
  },
34
118
  /** Nullish checks don't make any sense on `checkWrap`. */
35
- checkWrapOverrides: {
119
+ checkWrap: {
36
120
  isDefined: undefined,
37
121
  isNullish: undefined,
38
122
  },
39
- waitUntilOverrides: {
123
+ waitUntil: {
124
+ /**
125
+ * Repeatedly calls a callback until its output is a value that is defined (not `null` and
126
+ * not `undefined`). Once the callback output passes, it is returned. If the attempts time
127
+ * out, an error is thrown.
128
+ *
129
+ * Type guards the value.
130
+ *
131
+ * @example
132
+ *
133
+ * ```ts
134
+ * import {waitUntil} from '@augment-vir/assert';
135
+ *
136
+ * await waitUntil.isDefined(() => 0); // returns `0`
137
+ * await waitUntil.isDefined(() => ''); // returns `''`
138
+ * await waitUntil.isDefined(() => null); // throws an error
139
+ * await waitUntil.isDefined(() => undefined); // throws an error
140
+ * ```
141
+ *
142
+ * @returns The callback output once it passes.
143
+ * @throws {@link AssertionError} On timeout.
144
+ * @see
145
+ * - {@link waitUntil.isNullish} : the opposite assertion.
146
+ */
40
147
  isDefined: autoGuard(),
148
+ /**
149
+ * Repeatedly calls a callback until its output is a value that is nullish (`null` or
150
+ * `undefined`). Once the callback output passes, it is returned. If the attempts time out,
151
+ * an error is thrown.
152
+ *
153
+ * Type guards the value.
154
+ *
155
+ * @example
156
+ *
157
+ * ```ts
158
+ * import {waitUntil} from '@augment-vir/assert';
159
+ *
160
+ * await waitUntil.isNullish(() => 0); // throws an error
161
+ * await waitUntil.isNullish(() => ''); // throws an error
162
+ * await waitUntil.isNullish(() => null); // returns `null`
163
+ * await waitUntil.isNullish(() => undefined); // returns `undefined`
164
+ * ```
165
+ *
166
+ * @returns The callback output once it passes.
167
+ * @throws {@link AssertionError} On timeout.
168
+ * @see
169
+ * - {@link waitUntil.isDefined} : the opposite assertion.
170
+ */
171
+ isNullish: autoGuardSymbol,
41
172
  },
42
173
  };