@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.
- package/README.md +11 -0
- package/dist/assertions/boolean.d.ts +443 -17
- package/dist/assertions/boolean.js +365 -8
- package/dist/assertions/boundary.d.ts +657 -13
- package/dist/assertions/boundary.js +537 -5
- package/dist/assertions/enum.d.ts +236 -8
- package/dist/assertions/enum.js +197 -5
- package/dist/assertions/equality/entry-equality.d.ts +287 -11
- package/dist/assertions/equality/entry-equality.js +243 -6
- package/dist/assertions/equality/json-equality.d.ts +244 -15
- package/dist/assertions/equality/json-equality.js +207 -11
- package/dist/assertions/equality/simple-equality.d.ts +849 -28
- package/dist/assertions/equality/simple-equality.js +712 -6
- package/dist/assertions/equality/ts-type-equality.d.ts +37 -1
- package/dist/assertions/equality/ts-type-equality.js +13 -1
- package/dist/assertions/extendable-assertions.d.ts +288 -120
- package/dist/assertions/extendable-assertions.js +32 -60
- package/dist/assertions/http.d.ts +217 -10
- package/dist/assertions/http.js +182 -6
- package/dist/assertions/instance.d.ts +189 -8
- package/dist/assertions/instance.js +159 -5
- package/dist/assertions/keys.d.ts +658 -13
- package/dist/assertions/keys.js +556 -5
- package/dist/assertions/length.d.ts +381 -9
- package/dist/assertions/length.js +309 -5
- package/dist/assertions/nullish.d.ts +169 -7
- package/dist/assertions/nullish.js +137 -6
- package/dist/assertions/numeric.d.ts +965 -11
- package/dist/assertions/numeric.js +819 -1
- package/dist/assertions/output.d.ts +107 -7
- package/dist/assertions/output.js +92 -5
- package/dist/assertions/primitive.d.ts +416 -13
- package/dist/assertions/primitive.js +352 -6
- package/dist/assertions/promise.d.ts +640 -21
- package/dist/assertions/promise.js +536 -15
- package/dist/assertions/regexp.d.ts +202 -3
- package/dist/assertions/regexp.js +173 -1
- package/dist/assertions/runtime-type.d.ts +1822 -41
- package/dist/assertions/runtime-type.js +1558 -35
- package/dist/assertions/throws.d.ts +265 -17
- package/dist/assertions/throws.js +229 -17
- package/dist/assertions/uuid.d.ts +233 -10
- package/dist/assertions/uuid.js +195 -6
- package/dist/assertions/values.d.ts +1086 -15
- package/dist/assertions/values.js +907 -6
- package/dist/augments/assertion.error.d.ts +2 -1
- package/dist/augments/assertion.error.js +2 -1
- package/dist/augments/guards/assert-wrap.d.ts +82 -37
- package/dist/augments/guards/assert-wrap.js +13 -2
- package/dist/augments/guards/assert.d.ts +30 -14
- package/dist/augments/guards/assert.js +21 -4
- package/dist/augments/guards/check-wrap.d.ts +94 -51
- package/dist/augments/guards/check-wrap.js +11 -3
- package/dist/augments/guards/check.d.ts +87 -37
- package/dist/augments/guards/check.js +9 -2
- package/dist/augments/guards/wait-until.d.ts +110 -103
- package/dist/augments/guards/wait-until.js +18 -3
- package/dist/augments/if-equals.d.ts +4 -2
- package/dist/guard-types/assert-wrap-function.d.ts +5 -2
- package/dist/guard-types/check-function.d.ts +5 -2
- package/dist/guard-types/check-wrap-wrapper-function.d.ts +4 -1
- package/dist/guard-types/guard-group.d.ts +7 -8
- package/dist/guard-types/wait-until-function.d.ts +8 -3
- package/dist/guard-types/wait-until-function.js +1 -1
- package/package.json +21 -8
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { NarrowToActual, NarrowToExpected } from '@augment-vir/core';
|
|
2
2
|
import { AnyObject, MaybePromise, Values } from '@augment-vir/core';
|
|
3
3
|
import type { EmptyObject } from 'type-fest';
|
|
4
|
+
import { autoGuardSymbol } from '../guard-types/guard-override.js';
|
|
4
5
|
import type { WaitUntilOptions } from '../guard-types/wait-until-function.js';
|
|
5
6
|
declare function hasValue(parent: object, value: unknown, failureMessage?: string | undefined): void;
|
|
6
7
|
declare function lacksValue(parent: object, value: unknown, failureMessage?: string | undefined): void;
|
|
@@ -13,7 +14,8 @@ declare function isNotIn<const Parent extends object | string, const Child>(chil
|
|
|
13
14
|
* {@link Empty}.
|
|
14
15
|
*
|
|
15
16
|
* @category Assert : Util
|
|
16
|
-
* @
|
|
17
|
+
* @category Package : @augment-vir/assert
|
|
18
|
+
* @package [`@augment-vir/assert`](https://www.npmjs.com/package/@augment-vir/assert)
|
|
17
19
|
*/
|
|
18
20
|
export type CanBeEmpty = string | Map<any, any> | Set<any> | AnyObject | any[];
|
|
19
21
|
/**
|
|
@@ -22,84 +24,1153 @@ export type CanBeEmpty = string | Map<any, any> | Set<any> | AnyObject | any[];
|
|
|
22
24
|
* for them.)
|
|
23
25
|
*
|
|
24
26
|
* @category Assert : Util
|
|
25
|
-
* @
|
|
27
|
+
* @category Package : @augment-vir/assert
|
|
28
|
+
* @package [`@augment-vir/assert`](https://www.npmjs.com/package/@augment-vir/assert)
|
|
26
29
|
*/
|
|
27
30
|
export type Empty = '' | EmptyObject | [] | Map<any, any> | Set<any>;
|
|
28
31
|
declare function isEmpty<const Actual extends CanBeEmpty>(actual: Actual, failureMessage?: string | undefined): asserts actual is NarrowToActual<Actual, Empty>;
|
|
29
32
|
declare function isNotEmpty<const Actual extends CanBeEmpty>(actual: Actual, failureMessage?: string | undefined): asserts actual is Exclude<Actual, Empty>;
|
|
30
33
|
export declare const valueGuards: {
|
|
31
|
-
|
|
34
|
+
assert: {
|
|
32
35
|
/**
|
|
33
|
-
*
|
|
36
|
+
* Asserts that an object/array parent includes a child value through reference equality.
|
|
34
37
|
*
|
|
35
38
|
* Performs no type guarding.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* import {assert} from '@augment-vir/assert';
|
|
44
|
+
*
|
|
45
|
+
* const child = {a: 'a'};
|
|
46
|
+
*
|
|
47
|
+
* assert.hasValue({child}, child); // passes
|
|
48
|
+
* assert.hasValue({child: {a: 'a'}}, child); // fails
|
|
49
|
+
* assert.hasValue([child], child); // passes
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
53
|
+
* @see
|
|
54
|
+
* - {@link assert.lacksValue} : the opposite assertion.
|
|
55
|
+
* - {@link assert.hasValues} : the multi-value assertion.
|
|
36
56
|
*/
|
|
37
57
|
hasValue: typeof hasValue;
|
|
38
58
|
/**
|
|
39
|
-
*
|
|
59
|
+
* Asserts that an object/array parent does _not_ include a child value through reference
|
|
60
|
+
* equality.
|
|
40
61
|
*
|
|
41
62
|
* Performs no type guarding.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
*
|
|
66
|
+
* ```ts
|
|
67
|
+
* import {assert} from '@augment-vir/assert';
|
|
68
|
+
*
|
|
69
|
+
* const child = {a: 'a'};
|
|
70
|
+
*
|
|
71
|
+
* assert.lacksValue({child}, child); // fails
|
|
72
|
+
* assert.lacksValue({child: {a: 'a'}}, child); // passes
|
|
73
|
+
* assert.lacksValue([child], child); // fails
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
77
|
+
* @see
|
|
78
|
+
* - {@link assert.hasValue} : the opposite assertion.
|
|
79
|
+
* - {@link assert.lacksValues} : the multi-value assertion.
|
|
42
80
|
*/
|
|
43
81
|
lacksValue: typeof lacksValue;
|
|
44
82
|
/**
|
|
45
|
-
*
|
|
83
|
+
* Asserts that an object/array parent includes all child values through reference equality.
|
|
46
84
|
*
|
|
47
85
|
* Performs no type guarding.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
*
|
|
89
|
+
* ```ts
|
|
90
|
+
* import {assert} from '@augment-vir/assert';
|
|
91
|
+
*
|
|
92
|
+
* const child = {a: 'a'};
|
|
93
|
+
* const child2 = {b: 'b'};
|
|
94
|
+
*
|
|
95
|
+
* assert.hasValues({child, child2}, [
|
|
96
|
+
* child,
|
|
97
|
+
* child2,
|
|
98
|
+
* ]); // passes
|
|
99
|
+
* assert.hasValues({child: {a: 'a'}, child2}, [
|
|
100
|
+
* child,
|
|
101
|
+
* child2,
|
|
102
|
+
* ]); // fails
|
|
103
|
+
* assert.hasValues(
|
|
104
|
+
* [child],
|
|
105
|
+
* [
|
|
106
|
+
* child,
|
|
107
|
+
* child2,
|
|
108
|
+
* ],
|
|
109
|
+
* ); // passes
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
113
|
+
* @see
|
|
114
|
+
* - {@link assert.lacksValues} : the opposite assertion.
|
|
115
|
+
* - {@link assert.hasValue} : the single-value assertion.
|
|
48
116
|
*/
|
|
49
117
|
hasValues: typeof hasValues;
|
|
50
118
|
/**
|
|
51
|
-
*
|
|
119
|
+
* Asserts that an object/array parent includes none of the provided child values through
|
|
120
|
+
* reference equality.
|
|
52
121
|
*
|
|
53
122
|
* Performs no type guarding.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
*
|
|
126
|
+
* ```ts
|
|
127
|
+
* import {assert} from '@augment-vir/assert';
|
|
128
|
+
*
|
|
129
|
+
* const child = {a: 'a'};
|
|
130
|
+
* const child2 = {b: 'b'};
|
|
131
|
+
*
|
|
132
|
+
* assert.lacksValues({}, [
|
|
133
|
+
* child,
|
|
134
|
+
* child2,
|
|
135
|
+
* ]); // passes
|
|
136
|
+
* assert.lacksValues({child, child2}, [
|
|
137
|
+
* child,
|
|
138
|
+
* child2,
|
|
139
|
+
* ]); // fails
|
|
140
|
+
* assert.lacksValues({child: {a: 'a'}, child2}, [
|
|
141
|
+
* child,
|
|
142
|
+
* child2,
|
|
143
|
+
* ]); // fails
|
|
144
|
+
* ```
|
|
145
|
+
*
|
|
146
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
147
|
+
* @see
|
|
148
|
+
* - {@link assert.lacksValues} : the opposite assertion.
|
|
149
|
+
* - {@link assert.hasValue} : the single-value assertion.
|
|
54
150
|
*/
|
|
55
151
|
lacksValues: typeof lacksValues;
|
|
56
152
|
/**
|
|
57
|
-
*
|
|
153
|
+
* Asserts that child value is contained within a parent object, array, or string through
|
|
154
|
+
* reference equality.
|
|
58
155
|
*
|
|
59
156
|
* Type guards the child when possible.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
*
|
|
160
|
+
* ```ts
|
|
161
|
+
* import {assert} from '@augment-vir/assert';
|
|
162
|
+
*
|
|
163
|
+
* const child = {a: 'a'};
|
|
164
|
+
*
|
|
165
|
+
* assert.isIn(child, {child}); // passes
|
|
166
|
+
* assert.isIn('a', 'ab'); // passes
|
|
167
|
+
* assert.isIn(child, [child]); // passes
|
|
168
|
+
*
|
|
169
|
+
* assert.isIn(child, {child: {a: 'a'}}); // fails
|
|
170
|
+
* assert.isIn('a', 'bc'); // fails
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
174
|
+
* @see
|
|
175
|
+
* - {@link assert.isNotIn} : the opposite assertion.
|
|
60
176
|
*/
|
|
61
177
|
isIn: typeof isIn;
|
|
62
178
|
/**
|
|
63
|
-
*
|
|
179
|
+
* Asserts that child value is _not_ contained within a parent object, array, or string through
|
|
180
|
+
* reference equality.
|
|
64
181
|
*
|
|
65
182
|
* Type guards the child when possible.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
*
|
|
186
|
+
* ```ts
|
|
187
|
+
* import {assert} from '@augment-vir/assert';
|
|
188
|
+
*
|
|
189
|
+
* const child = {a: 'a'};
|
|
190
|
+
*
|
|
191
|
+
* assert.isNotIn(child, {child}); // fails
|
|
192
|
+
* assert.isNotIn('a', 'ab'); // fails
|
|
193
|
+
* assert.isNotIn(child, [child]); // fails
|
|
194
|
+
*
|
|
195
|
+
* assert.isNotIn(child, {child: {a: 'a'}}); // passes
|
|
196
|
+
* assert.isNotIn('a', 'bc'); // passes
|
|
197
|
+
* ```
|
|
198
|
+
*
|
|
199
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
200
|
+
* @see
|
|
201
|
+
* - {@link assert.isIn} : the opposite assertion.
|
|
66
202
|
*/
|
|
67
203
|
isNotIn: typeof isNotIn;
|
|
68
204
|
/**
|
|
69
|
-
*
|
|
205
|
+
* Asserts that a value is empty. Supports strings, Maps, Sets, objects, and arrays.
|
|
70
206
|
*
|
|
71
207
|
* Type guards the value.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
*
|
|
211
|
+
* ```ts
|
|
212
|
+
* import {assert} from '@augment-vir/assert';
|
|
213
|
+
*
|
|
214
|
+
* assert.isEmpty({}); // passes
|
|
215
|
+
* assert.isEmpty(''); // passes
|
|
216
|
+
* assert.isEmpty([]); // passes
|
|
217
|
+
*
|
|
218
|
+
* assert.isEmpty('a'); // fails
|
|
219
|
+
* assert.isEmpty({a: 'a'}); // fails
|
|
220
|
+
* ```
|
|
221
|
+
*
|
|
222
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
223
|
+
* @see
|
|
224
|
+
* - {@link assert.isNotEmpty} : the opposite assertion.
|
|
72
225
|
*/
|
|
73
226
|
isEmpty: typeof isEmpty;
|
|
74
227
|
/**
|
|
75
|
-
*
|
|
228
|
+
* Asserts that a value is _not_ empty. Supports strings, Maps, Sets, objects, and arrays.
|
|
76
229
|
*
|
|
77
230
|
* Type guards the value.
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
*
|
|
234
|
+
* ```ts
|
|
235
|
+
* import {assert} from '@augment-vir/assert';
|
|
236
|
+
*
|
|
237
|
+
* assert.isNotEmpty({}); // fails
|
|
238
|
+
* assert.isNotEmpty(''); // fails
|
|
239
|
+
* assert.isNotEmpty([]); // fails
|
|
240
|
+
*
|
|
241
|
+
* assert.isNotEmpty('a'); // passes
|
|
242
|
+
* assert.isNotEmpty({a: 'a'}); // passes
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
246
|
+
* @see
|
|
247
|
+
* - {@link assert.isEmpty} : the opposite assertion.
|
|
78
248
|
*/
|
|
79
249
|
isNotEmpty: typeof isNotEmpty;
|
|
80
250
|
};
|
|
81
|
-
|
|
251
|
+
check: {
|
|
252
|
+
/**
|
|
253
|
+
* Checks that an object/array parent includes a child value through reference equality.
|
|
254
|
+
*
|
|
255
|
+
* Performs no type guarding.
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
*
|
|
259
|
+
* ```ts
|
|
260
|
+
* import {check} from '@augment-vir/assert';
|
|
261
|
+
*
|
|
262
|
+
* const child = {a: 'a'};
|
|
263
|
+
*
|
|
264
|
+
* check.hasValue({child}, child); // returns `true`
|
|
265
|
+
* check.hasValue({child: {a: 'a'}}, child); // returns `false`
|
|
266
|
+
* check.hasValue([child], child); // returns `true`
|
|
267
|
+
* ```
|
|
268
|
+
*
|
|
269
|
+
* @see
|
|
270
|
+
* - {@link check.lacksValue} : the opposite check.
|
|
271
|
+
* - {@link check.hasValues} : the multi-value check.
|
|
272
|
+
*/
|
|
273
|
+
hasValue: typeof autoGuardSymbol;
|
|
274
|
+
/**
|
|
275
|
+
* Checks that an object/array parent does _not_ include a child value through reference
|
|
276
|
+
* equality.
|
|
277
|
+
*
|
|
278
|
+
* Performs no type guarding.
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
*
|
|
282
|
+
* ```ts
|
|
283
|
+
* import {check} from '@augment-vir/assert';
|
|
284
|
+
*
|
|
285
|
+
* const child = {a: 'a'};
|
|
286
|
+
*
|
|
287
|
+
* check.lacksValue({child}, child); // returns `false`
|
|
288
|
+
* check.lacksValue({child: {a: 'a'}}, child); // returns `true`
|
|
289
|
+
* check.lacksValue([child], child); // returns `false`
|
|
290
|
+
* ```
|
|
291
|
+
*
|
|
292
|
+
* @see
|
|
293
|
+
* - {@link check.hasValue} : the opposite check.
|
|
294
|
+
* - {@link check.lacksValues} : the multi-value check.
|
|
295
|
+
*/
|
|
296
|
+
lacksValue: typeof autoGuardSymbol;
|
|
297
|
+
/**
|
|
298
|
+
* Checks that an object/array parent includes all child values through reference equality.
|
|
299
|
+
*
|
|
300
|
+
* Performs no type guarding.
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
*
|
|
304
|
+
* ```ts
|
|
305
|
+
* import {check} from '@augment-vir/assert';
|
|
306
|
+
*
|
|
307
|
+
* const child = {a: 'a'};
|
|
308
|
+
* const child2 = {b: 'b'};
|
|
309
|
+
*
|
|
310
|
+
* check.hasValues({child, child2}, [
|
|
311
|
+
* child,
|
|
312
|
+
* child2,
|
|
313
|
+
* ]); // returns `true`
|
|
314
|
+
* check.hasValues({child: {a: 'a'}, child2}, [
|
|
315
|
+
* child,
|
|
316
|
+
* child2,
|
|
317
|
+
* ]); // returns `false`
|
|
318
|
+
* check.hasValues(
|
|
319
|
+
* [child],
|
|
320
|
+
* [
|
|
321
|
+
* child,
|
|
322
|
+
* child2,
|
|
323
|
+
* ],
|
|
324
|
+
* ); // returns `true`
|
|
325
|
+
* ```
|
|
326
|
+
*
|
|
327
|
+
* @see
|
|
328
|
+
* - {@link check.lacksValues} : the opposite check.
|
|
329
|
+
* - {@link check.hasValue} : the single-value check.
|
|
330
|
+
*/
|
|
331
|
+
hasValues: typeof autoGuardSymbol;
|
|
332
|
+
/**
|
|
333
|
+
* Checks that an object/array parent includes none of the provided child values through
|
|
334
|
+
* reference equality.
|
|
335
|
+
*
|
|
336
|
+
* Performs no type guarding.
|
|
337
|
+
*
|
|
338
|
+
* @example
|
|
339
|
+
*
|
|
340
|
+
* ```ts
|
|
341
|
+
* import {check} from '@augment-vir/assert';
|
|
342
|
+
*
|
|
343
|
+
* const child = {a: 'a'};
|
|
344
|
+
* const child2 = {b: 'b'};
|
|
345
|
+
*
|
|
346
|
+
* check.lacksValues({}, [
|
|
347
|
+
* child,
|
|
348
|
+
* child2,
|
|
349
|
+
* ]); // returns `true`
|
|
350
|
+
* check.lacksValues({child, child2}, [
|
|
351
|
+
* child,
|
|
352
|
+
* child2,
|
|
353
|
+
* ]); // returns `false`
|
|
354
|
+
* check.lacksValues({child: {a: 'a'}, child2}, [
|
|
355
|
+
* child,
|
|
356
|
+
* child2,
|
|
357
|
+
* ]); // returns `false`
|
|
358
|
+
* ```
|
|
359
|
+
*
|
|
360
|
+
* @see
|
|
361
|
+
* - {@link check.lacksValues} : the opposite check.
|
|
362
|
+
* - {@link check.hasValue} : the single-value check.
|
|
363
|
+
*/
|
|
364
|
+
lacksValues: typeof autoGuardSymbol;
|
|
365
|
+
/**
|
|
366
|
+
* Checks that child value is contained within a parent object, array, or string through
|
|
367
|
+
* reference equality.
|
|
368
|
+
*
|
|
369
|
+
* Type guards the child when possible.
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
*
|
|
373
|
+
* ```ts
|
|
374
|
+
* import {check} from '@augment-vir/assert';
|
|
375
|
+
*
|
|
376
|
+
* const child = {a: 'a'};
|
|
377
|
+
*
|
|
378
|
+
* check.isIn(child, {child}); // returns `true`
|
|
379
|
+
* check.isIn('a', 'ab'); // returns `true`
|
|
380
|
+
* check.isIn(child, [child]); // returns `true`
|
|
381
|
+
*
|
|
382
|
+
* check.isIn(child, {child: {a: 'a'}}); // returns `false`
|
|
383
|
+
* check.isIn('a', 'bc'); // returns `false`
|
|
384
|
+
* ```
|
|
385
|
+
*
|
|
386
|
+
* @see
|
|
387
|
+
* - {@link check.isNotIn} : the opposite check.
|
|
388
|
+
*/
|
|
82
389
|
isIn: <const Parent>(child: unknown, parent: Parent) => child is Values<Parent>;
|
|
390
|
+
/**
|
|
391
|
+
* Checks that child value is _not_ contained within a parent object, array, or string
|
|
392
|
+
* through reference equality.
|
|
393
|
+
*
|
|
394
|
+
* Type guards the child when possible.
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
*
|
|
398
|
+
* ```ts
|
|
399
|
+
* import {check} from '@augment-vir/assert';
|
|
400
|
+
*
|
|
401
|
+
* const child = {a: 'a'};
|
|
402
|
+
*
|
|
403
|
+
* check.isNotIn(child, {child}); // returns `false`
|
|
404
|
+
* check.isNotIn('a', 'ab'); // returns `false`
|
|
405
|
+
* check.isNotIn(child, [child]); // returns `false`
|
|
406
|
+
*
|
|
407
|
+
* check.isNotIn(child, {child: {a: 'a'}}); // returns `true`
|
|
408
|
+
* check.isNotIn('a', 'bc'); // returns `true`
|
|
409
|
+
* ```
|
|
410
|
+
*
|
|
411
|
+
* @see
|
|
412
|
+
* - {@link check.isIn} : the opposite check.
|
|
413
|
+
*/
|
|
83
414
|
isNotIn: <const Parent, const Child>(child: Child, parent: Parent, failureMessage?: string | undefined) => child is Exclude<Child, Values<Parent>>;
|
|
415
|
+
/**
|
|
416
|
+
* Checks that a value is empty. Supports strings, Maps, Sets, objects, and arrays.
|
|
417
|
+
*
|
|
418
|
+
* Type guards the value.
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
*
|
|
422
|
+
* ```ts
|
|
423
|
+
* import {check} from '@augment-vir/assert';
|
|
424
|
+
*
|
|
425
|
+
* check.isEmpty({}); // returns `true`
|
|
426
|
+
* check.isEmpty(''); // returns `true`
|
|
427
|
+
* check.isEmpty([]); // returns `true`
|
|
428
|
+
*
|
|
429
|
+
* check.isEmpty('a'); // returns `false`
|
|
430
|
+
* check.isEmpty({a: 'a'}); // returns `false`
|
|
431
|
+
* ```
|
|
432
|
+
*
|
|
433
|
+
* @see
|
|
434
|
+
* - {@link check.isNotEmpty} : the opposite check.
|
|
435
|
+
*/
|
|
84
436
|
isEmpty: <const Actual extends CanBeEmpty>(actual: Actual) => actual is NarrowToActual<Actual, Empty>;
|
|
437
|
+
/**
|
|
438
|
+
* Checks that a value is _not_ empty. Supports strings, Maps, Sets, objects, and arrays.
|
|
439
|
+
*
|
|
440
|
+
* Type guards the value.
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
*
|
|
444
|
+
* ```ts
|
|
445
|
+
* import {check} from '@augment-vir/assert';
|
|
446
|
+
*
|
|
447
|
+
* check.isNotEmpty({}); // returns `false`
|
|
448
|
+
* check.isNotEmpty(''); // returns `false`
|
|
449
|
+
* check.isNotEmpty([]); // returns `false`
|
|
450
|
+
*
|
|
451
|
+
* check.isNotEmpty('a'); // returns `true`
|
|
452
|
+
* check.isNotEmpty({a: 'a'}); // returns `true`
|
|
453
|
+
* ```
|
|
454
|
+
*
|
|
455
|
+
* @see
|
|
456
|
+
* - {@link check.isEmpty} : the opposite check.
|
|
457
|
+
*/
|
|
85
458
|
isNotEmpty: <const Actual extends CanBeEmpty>(actual: Actual) => actual is Exclude<Actual, Empty>;
|
|
86
459
|
};
|
|
87
|
-
|
|
460
|
+
assertWrap: {
|
|
461
|
+
/**
|
|
462
|
+
* Asserts that an object/array parent includes a child value through reference equality.
|
|
463
|
+
* Returns the parent value if the assertion passes.
|
|
464
|
+
*
|
|
465
|
+
* Performs no type guarding.
|
|
466
|
+
*
|
|
467
|
+
* @example
|
|
468
|
+
*
|
|
469
|
+
* ```ts
|
|
470
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
471
|
+
*
|
|
472
|
+
* const child = {a: 'a'};
|
|
473
|
+
*
|
|
474
|
+
* assertWrap.hasValue({child}, child); // returns `{child}`;
|
|
475
|
+
* assertWrap.hasValue({child: {a: 'a'}}, child); // throws an error
|
|
476
|
+
* assertWrap.hasValue([child], child); // returns `[child]`;
|
|
477
|
+
* ```
|
|
478
|
+
*
|
|
479
|
+
* @returns The value if the assertion passes.
|
|
480
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
481
|
+
* @see
|
|
482
|
+
* - {@link assertWrap.lacksValue} : the opposite assertion.
|
|
483
|
+
* - {@link assertWrap.hasValues} : the multi-value assertion.
|
|
484
|
+
*/
|
|
485
|
+
hasValue: typeof autoGuardSymbol;
|
|
486
|
+
/**
|
|
487
|
+
* Asserts that an object/array parent does _not_ include a child value through reference
|
|
488
|
+
* equality. Returns the parent value if the assertion passes.
|
|
489
|
+
*
|
|
490
|
+
* Performs no type guarding.
|
|
491
|
+
*
|
|
492
|
+
* @example
|
|
493
|
+
*
|
|
494
|
+
* ```ts
|
|
495
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
496
|
+
*
|
|
497
|
+
* const child = {a: 'a'};
|
|
498
|
+
*
|
|
499
|
+
* assertWrap.lacksValue({child}, child); // throws an error
|
|
500
|
+
* assertWrap.lacksValue({child: {a: 'a'}}, child); // returns `{child: {a: 'a'}}`;
|
|
501
|
+
* assertWrap.lacksValue([child], child); // throws an error
|
|
502
|
+
* ```
|
|
503
|
+
*
|
|
504
|
+
* @returns The value if the assertion passes.
|
|
505
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
506
|
+
* @see
|
|
507
|
+
* - {@link assertWrap.hasValue} : the opposite assertion.
|
|
508
|
+
* - {@link assertWrap.lacksValues} : the multi-value assertion.
|
|
509
|
+
*/
|
|
510
|
+
lacksValue: typeof autoGuardSymbol;
|
|
511
|
+
/**
|
|
512
|
+
* Asserts that an object/array parent includes all child values through reference equality.
|
|
513
|
+
* Returns the parent value if the assertion passes.
|
|
514
|
+
*
|
|
515
|
+
* Performs no type guarding.
|
|
516
|
+
*
|
|
517
|
+
* @example
|
|
518
|
+
*
|
|
519
|
+
* ```ts
|
|
520
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
521
|
+
*
|
|
522
|
+
* const child = {a: 'a'};
|
|
523
|
+
* const child2 = {b: 'b'};
|
|
524
|
+
*
|
|
525
|
+
* assertWrap.hasValues({child, child2}, [
|
|
526
|
+
* child,
|
|
527
|
+
* child2,
|
|
528
|
+
* ]); // returns `{child, child2}`;
|
|
529
|
+
* assertWrap.hasValues({child: {a: 'a'}, child2}, [
|
|
530
|
+
* child,
|
|
531
|
+
* child2,
|
|
532
|
+
* ]); // throws an error
|
|
533
|
+
* assertWrap.hasValues(
|
|
534
|
+
* [child],
|
|
535
|
+
* [
|
|
536
|
+
* child,
|
|
537
|
+
* child2,
|
|
538
|
+
* ],
|
|
539
|
+
* ); // returns `[child]`;
|
|
540
|
+
* ```
|
|
541
|
+
*
|
|
542
|
+
* @returns The value if the assertion passes.
|
|
543
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
544
|
+
* @see
|
|
545
|
+
* - {@link assertWrap.lacksValues} : the opposite assertion.
|
|
546
|
+
* - {@link assertWrap.hasValue} : the single-value assertion.
|
|
547
|
+
*/
|
|
548
|
+
hasValues: typeof autoGuardSymbol;
|
|
549
|
+
/**
|
|
550
|
+
* Asserts that an object/array parent includes none of the provided child values through
|
|
551
|
+
* reference equality. Returns the parent value if the assertion passes.
|
|
552
|
+
*
|
|
553
|
+
* Performs no type guarding.
|
|
554
|
+
*
|
|
555
|
+
* @example
|
|
556
|
+
*
|
|
557
|
+
* ```ts
|
|
558
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
559
|
+
*
|
|
560
|
+
* const child = {a: 'a'};
|
|
561
|
+
* const child2 = {b: 'b'};
|
|
562
|
+
*
|
|
563
|
+
* assertWrap.lacksValues({}, [
|
|
564
|
+
* child,
|
|
565
|
+
* child2,
|
|
566
|
+
* ]); // returns `{}`;
|
|
567
|
+
* assertWrap.lacksValues({child, child2}, [
|
|
568
|
+
* child,
|
|
569
|
+
* child2,
|
|
570
|
+
* ]); // throws an error
|
|
571
|
+
* assertWrap.lacksValues({child: {a: 'a'}, child2}, [
|
|
572
|
+
* child,
|
|
573
|
+
* child2,
|
|
574
|
+
* ]); // throws an error
|
|
575
|
+
* ```
|
|
576
|
+
*
|
|
577
|
+
* @returns The value if the assertion passes.
|
|
578
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
579
|
+
* @see
|
|
580
|
+
* - {@link assertWrap.lacksValues} : the opposite assertion.
|
|
581
|
+
* - {@link assertWrap.hasValue} : the single-value assertion.
|
|
582
|
+
*/
|
|
583
|
+
lacksValues: typeof autoGuardSymbol;
|
|
584
|
+
/**
|
|
585
|
+
* Asserts that child value is contained within a parent object, array, or string through
|
|
586
|
+
* reference equality. Returns the child value if the assertion passes.
|
|
587
|
+
*
|
|
588
|
+
* Type guards the child when possible.
|
|
589
|
+
*
|
|
590
|
+
* @example
|
|
591
|
+
*
|
|
592
|
+
* ```ts
|
|
593
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
594
|
+
*
|
|
595
|
+
* const child = {a: 'a'};
|
|
596
|
+
*
|
|
597
|
+
* assertWrap.isIn(child, {child}); // returns `child`;
|
|
598
|
+
* assertWrap.isIn('a', 'ab'); // returns `'a'`;
|
|
599
|
+
* assertWrap.isIn(child, [child]); // returns `child`;
|
|
600
|
+
*
|
|
601
|
+
* assertWrap.isIn(child, {child: {a: 'a'}}); // throws an error
|
|
602
|
+
* assertWrap.isIn('a', 'bc'); // throws an error
|
|
603
|
+
* ```
|
|
604
|
+
*
|
|
605
|
+
* @returns The value if the assertion passes.
|
|
606
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
607
|
+
* @see
|
|
608
|
+
* - {@link assertWrap.isNotIn} : the opposite assertion.
|
|
609
|
+
*/
|
|
88
610
|
isIn: <const Child, const Parent>(child: Child, parent: Parent, failureMessage?: string | undefined) => NarrowToExpected<Child, Values<Parent>>;
|
|
611
|
+
/**
|
|
612
|
+
* Asserts that child value is _not_ contained within a parent object, array, or string
|
|
613
|
+
* through reference equality. Returns the child value if the assertion passes.
|
|
614
|
+
*
|
|
615
|
+
* Type guards the child when possible.
|
|
616
|
+
*
|
|
617
|
+
* @example
|
|
618
|
+
*
|
|
619
|
+
* ```ts
|
|
620
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
621
|
+
*
|
|
622
|
+
* const child = {a: 'a'};
|
|
623
|
+
*
|
|
624
|
+
* assertWrap.isNotIn(child, {child}); // throws an error
|
|
625
|
+
* assertWrap.isNotIn('a', 'ab'); // throws an error
|
|
626
|
+
* assertWrap.isNotIn(child, [child]); // throws an error
|
|
627
|
+
*
|
|
628
|
+
* assertWrap.isNotIn(child, {child: {a: 'a'}}); // returns `child`;
|
|
629
|
+
* assertWrap.isNotIn('a', 'bc'); // returns `'a'`;
|
|
630
|
+
* ```
|
|
631
|
+
*
|
|
632
|
+
* @returns The value if the assertion passes.
|
|
633
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
634
|
+
* @see
|
|
635
|
+
* - {@link assertWrap.isIn} : the opposite assertion.
|
|
636
|
+
*/
|
|
89
637
|
isNotIn: <const Parent, const Child>(child: Child, parent: Parent, failureMessage?: string | undefined) => Exclude<Child, Values<Parent>>;
|
|
638
|
+
/**
|
|
639
|
+
* Asserts that a value is empty. Supports strings, Maps, Sets, objects, and arrays. Returns
|
|
640
|
+
* the value if the assertion passes.
|
|
641
|
+
*
|
|
642
|
+
* Type guards the value.
|
|
643
|
+
*
|
|
644
|
+
* @example
|
|
645
|
+
*
|
|
646
|
+
* ```ts
|
|
647
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
648
|
+
*
|
|
649
|
+
* assertWrap.isEmpty({}); // returns `{}`;
|
|
650
|
+
* assertWrap.isEmpty(''); // returns `''`;
|
|
651
|
+
* assertWrap.isEmpty([]); // returns `[]`;
|
|
652
|
+
*
|
|
653
|
+
* assertWrap.isEmpty('a'); // throws an error
|
|
654
|
+
* assertWrap.isEmpty({a: 'a'}); // throws an error
|
|
655
|
+
* ```
|
|
656
|
+
*
|
|
657
|
+
* @returns The value if the assertion passes.
|
|
658
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
659
|
+
* @see
|
|
660
|
+
* - {@link assertWrap.isNotEmpty} : the opposite assertion.
|
|
661
|
+
*/
|
|
90
662
|
isEmpty: <const Actual extends CanBeEmpty>(actual: Actual, failureMessage?: string | undefined) => NarrowToActual<Actual, Empty>;
|
|
663
|
+
/**
|
|
664
|
+
* Asserts that a value is _not_ empty. Supports strings, Maps, Sets, objects, and arrays.
|
|
665
|
+
* Returns the value if the assertion passes.
|
|
666
|
+
*
|
|
667
|
+
* Type guards the value.
|
|
668
|
+
*
|
|
669
|
+
* @example
|
|
670
|
+
*
|
|
671
|
+
* ```ts
|
|
672
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
673
|
+
*
|
|
674
|
+
* assertWrap.isNotEmpty({}); // throws an error
|
|
675
|
+
* assertWrap.isNotEmpty(''); // throws an error
|
|
676
|
+
* assertWrap.isNotEmpty([]); // throws an error
|
|
677
|
+
*
|
|
678
|
+
* assertWrap.isNotEmpty('a'); // returns `'a'`;
|
|
679
|
+
* assertWrap.isNotEmpty({a: 'a'}); // returns `{a: 'a'}`;
|
|
680
|
+
* ```
|
|
681
|
+
*
|
|
682
|
+
* @returns The value if the assertion passes.
|
|
683
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
684
|
+
* @see
|
|
685
|
+
* - {@link assertWrap.isEmpty} : the opposite assertion.
|
|
686
|
+
*/
|
|
91
687
|
isNotEmpty: <const Actual extends CanBeEmpty>(actual: Actual) => Exclude<Actual, Empty>;
|
|
92
688
|
};
|
|
93
|
-
|
|
689
|
+
checkWrap: {
|
|
690
|
+
/**
|
|
691
|
+
* Checks that an object/array parent includes a child value through reference equality.
|
|
692
|
+
*
|
|
693
|
+
* Performs no type guarding.
|
|
694
|
+
*
|
|
695
|
+
* @example
|
|
696
|
+
*
|
|
697
|
+
* ```ts
|
|
698
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
699
|
+
*
|
|
700
|
+
* const child = {a: 'a'};
|
|
701
|
+
*
|
|
702
|
+
* checkWrap.hasValue({child}, child); // returns `{child}`
|
|
703
|
+
* checkWrap.hasValue({child: {a: 'a'}}, child); // returns `undefined`
|
|
704
|
+
* checkWrap.hasValue([child], child); // returns `[child]`
|
|
705
|
+
* ```
|
|
706
|
+
*
|
|
707
|
+
* @see
|
|
708
|
+
* - {@link checkWrap.lacksValue} : the opposite check.
|
|
709
|
+
* - {@link checkWrap.hasValues} : the multi-value check.
|
|
710
|
+
*/
|
|
711
|
+
hasValue: typeof autoGuardSymbol;
|
|
712
|
+
/**
|
|
713
|
+
* Checks that an object/array parent does _not_ include a child value through reference
|
|
714
|
+
* equality.
|
|
715
|
+
*
|
|
716
|
+
* Performs no type guarding.
|
|
717
|
+
*
|
|
718
|
+
* @example
|
|
719
|
+
*
|
|
720
|
+
* ```ts
|
|
721
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
722
|
+
*
|
|
723
|
+
* const child = {a: 'a'};
|
|
724
|
+
*
|
|
725
|
+
* checkWrap.lacksValue({child}, child); // returns `undefined`
|
|
726
|
+
* checkWrap.lacksValue({child: {a: 'a'}}, child); // returns `{child: {a: 'a'}}`
|
|
727
|
+
* checkWrap.lacksValue([child], child); // returns `undefined`
|
|
728
|
+
* ```
|
|
729
|
+
*
|
|
730
|
+
* @see
|
|
731
|
+
* - {@link checkWrap.hasValue} : the opposite check.
|
|
732
|
+
* - {@link checkWrap.lacksValues} : the multi-value check.
|
|
733
|
+
*/
|
|
734
|
+
lacksValue: typeof autoGuardSymbol;
|
|
735
|
+
/**
|
|
736
|
+
* Checks that an object/array parent includes all child values through reference equality.
|
|
737
|
+
*
|
|
738
|
+
* Performs no type guarding.
|
|
739
|
+
*
|
|
740
|
+
* @example
|
|
741
|
+
*
|
|
742
|
+
* ```ts
|
|
743
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
744
|
+
*
|
|
745
|
+
* const child = {a: 'a'};
|
|
746
|
+
* const child2 = {b: 'b'};
|
|
747
|
+
*
|
|
748
|
+
* checkWrap.hasValues({child, child2}, [
|
|
749
|
+
* child,
|
|
750
|
+
* child2,
|
|
751
|
+
* ]); // returns `{child, child2}`
|
|
752
|
+
* checkWrap.hasValues({child: {a: 'a'}, child2}, [
|
|
753
|
+
* child,
|
|
754
|
+
* child2,
|
|
755
|
+
* ]); // returns `undefined`
|
|
756
|
+
* checkWrap.hasValues(
|
|
757
|
+
* [child],
|
|
758
|
+
* [
|
|
759
|
+
* child,
|
|
760
|
+
* child2,
|
|
761
|
+
* ],
|
|
762
|
+
* ); // returns `[child]`
|
|
763
|
+
* ```
|
|
764
|
+
*
|
|
765
|
+
* @see
|
|
766
|
+
* - {@link checkWrap.lacksValues} : the opposite check.
|
|
767
|
+
* - {@link checkWrap.hasValue} : the single-value check.
|
|
768
|
+
*/
|
|
769
|
+
hasValues: typeof autoGuardSymbol;
|
|
770
|
+
/**
|
|
771
|
+
* Checks that an object/array parent includes none of the provided child values through
|
|
772
|
+
* reference equality.
|
|
773
|
+
*
|
|
774
|
+
* Performs no type guarding.
|
|
775
|
+
*
|
|
776
|
+
* @example
|
|
777
|
+
*
|
|
778
|
+
* ```ts
|
|
779
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
780
|
+
*
|
|
781
|
+
* const child = {a: 'a'};
|
|
782
|
+
* const child2 = {b: 'b'};
|
|
783
|
+
*
|
|
784
|
+
* checkWrap.lacksValues({}, [
|
|
785
|
+
* child,
|
|
786
|
+
* child2,
|
|
787
|
+
* ]); // returns `{}`
|
|
788
|
+
* checkWrap.lacksValues({child, child2}, [
|
|
789
|
+
* child,
|
|
790
|
+
* child2,
|
|
791
|
+
* ]); // returns `undefined`
|
|
792
|
+
* checkWrap.lacksValues({child: {a: 'a'}, child2}, [
|
|
793
|
+
* child,
|
|
794
|
+
* child2,
|
|
795
|
+
* ]); // returns `undefined`
|
|
796
|
+
* ```
|
|
797
|
+
*
|
|
798
|
+
* @see
|
|
799
|
+
* - {@link checkWrap.lacksValues} : the opposite check.
|
|
800
|
+
* - {@link checkWrap.hasValue} : the single-value check.
|
|
801
|
+
*/
|
|
802
|
+
lacksValues: typeof autoGuardSymbol;
|
|
803
|
+
/**
|
|
804
|
+
* Checks that child value is contained within a parent object, array, or string through
|
|
805
|
+
* reference equality.
|
|
806
|
+
*
|
|
807
|
+
* Type guards the child when possible.
|
|
808
|
+
*
|
|
809
|
+
* @example
|
|
810
|
+
*
|
|
811
|
+
* ```ts
|
|
812
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
813
|
+
*
|
|
814
|
+
* const child = {a: 'a'};
|
|
815
|
+
*
|
|
816
|
+
* checkWrap.isIn(child, {child}); // returns `child`
|
|
817
|
+
* checkWrap.isIn('a', 'ab'); // returns `'a'`
|
|
818
|
+
* checkWrap.isIn(child, [child]); // returns `child`
|
|
819
|
+
*
|
|
820
|
+
* checkWrap.isIn(child, {child: {a: 'a'}}); // returns `undefined`
|
|
821
|
+
* checkWrap.isIn('a', 'bc'); // returns `undefined`
|
|
822
|
+
* ```
|
|
823
|
+
*
|
|
824
|
+
* @see
|
|
825
|
+
* - {@link checkWrap.isNotIn} : the opposite check.
|
|
826
|
+
*/
|
|
94
827
|
isIn: <const Child, const Parent>(child: Child, parent: Parent) => NarrowToExpected<Child, Values<Parent>> | undefined;
|
|
828
|
+
/**
|
|
829
|
+
* Checks that child value is _not_ contained within a parent object, array, or string
|
|
830
|
+
* through reference equality.
|
|
831
|
+
*
|
|
832
|
+
* Type guards the child when possible.
|
|
833
|
+
*
|
|
834
|
+
* @example
|
|
835
|
+
*
|
|
836
|
+
* ```ts
|
|
837
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
838
|
+
*
|
|
839
|
+
* const child = {a: 'a'};
|
|
840
|
+
*
|
|
841
|
+
* checkWrap.isNotIn(child, {child}); // returns `undefined`
|
|
842
|
+
* checkWrap.isNotIn('a', 'ab'); // returns `undefined`
|
|
843
|
+
* checkWrap.isNotIn(child, [child]); // returns `undefined`
|
|
844
|
+
*
|
|
845
|
+
* checkWrap.isNotIn(child, {child: {a: 'a'}}); // returns `child`
|
|
846
|
+
* checkWrap.isNotIn('a', 'bc'); // returns `'a'`
|
|
847
|
+
* ```
|
|
848
|
+
*
|
|
849
|
+
* @see
|
|
850
|
+
* - {@link checkWrap.isIn} : the opposite check.
|
|
851
|
+
*/
|
|
95
852
|
isNotIn: <const Parent, const Child>(child: Child, parent: Parent, failureMessage?: string | undefined) => Exclude<Child, Values<Parent>> | undefined;
|
|
853
|
+
/**
|
|
854
|
+
* Checks that a value is empty. Supports strings, Maps, Sets, objects, and arrays.
|
|
855
|
+
*
|
|
856
|
+
* Type guards the value.
|
|
857
|
+
*
|
|
858
|
+
* @example
|
|
859
|
+
*
|
|
860
|
+
* ```ts
|
|
861
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
862
|
+
*
|
|
863
|
+
* checkWrap.isEmpty({}); // returns `{}`
|
|
864
|
+
* checkWrap.isEmpty(''); // returns `''`
|
|
865
|
+
* checkWrap.isEmpty([]); // returns `[]`
|
|
866
|
+
*
|
|
867
|
+
* checkWrap.isEmpty('a'); // returns `undefined`
|
|
868
|
+
* checkWrap.isEmpty({a: 'a'}); // returns `undefined`
|
|
869
|
+
* ```
|
|
870
|
+
*
|
|
871
|
+
* @see
|
|
872
|
+
* - {@link checkWrap.isNotEmpty} : the opposite check.
|
|
873
|
+
*/
|
|
96
874
|
isEmpty: <const Actual extends CanBeEmpty>(actual: Actual) => NarrowToActual<Actual, Empty> | undefined;
|
|
875
|
+
/**
|
|
876
|
+
* Checks that a value is _not_ empty. Supports strings, Maps, Sets, objects, and arrays.
|
|
877
|
+
*
|
|
878
|
+
* Type guards the value.
|
|
879
|
+
*
|
|
880
|
+
* @example
|
|
881
|
+
*
|
|
882
|
+
* ```ts
|
|
883
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
884
|
+
*
|
|
885
|
+
* checkWrap.isNotEmpty({}); // returns `undefined`
|
|
886
|
+
* checkWrap.isNotEmpty(''); // returns `undefined`
|
|
887
|
+
* checkWrap.isNotEmpty([]); // returns `undefined`
|
|
888
|
+
*
|
|
889
|
+
* checkWrap.isNotEmpty('a'); // returns `'a'`
|
|
890
|
+
* checkWrap.isNotEmpty({a: 'a'}); // returns `{a: 'a'}`
|
|
891
|
+
* ```
|
|
892
|
+
*
|
|
893
|
+
* @see
|
|
894
|
+
* - {@link checkWrap.isEmpty} : the opposite check.
|
|
895
|
+
*/
|
|
97
896
|
isNotEmpty: <const Actual extends CanBeEmpty>(actual: Actual) => Exclude<Actual, Empty> | undefined;
|
|
98
897
|
};
|
|
99
|
-
|
|
898
|
+
waitUntil: {
|
|
899
|
+
/**
|
|
900
|
+
* Repeatedly calls a callback until its output is an object/array parent includes a child
|
|
901
|
+
* value through reference equality. Once the callback output passes, it is returned. If the
|
|
902
|
+
* attempts time out, an error is thrown.
|
|
903
|
+
*
|
|
904
|
+
* Performs no type guarding.
|
|
905
|
+
*
|
|
906
|
+
* @example
|
|
907
|
+
*
|
|
908
|
+
* ```ts
|
|
909
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
910
|
+
*
|
|
911
|
+
* const child = {a: 'a'};
|
|
912
|
+
*
|
|
913
|
+
* await waitUntil.hasValue(child, () => {
|
|
914
|
+
* return {child};
|
|
915
|
+
* }); // returns `{child}`;
|
|
916
|
+
* await waitUntil.hasValue(child, () => {
|
|
917
|
+
* return {child: {a: 'a'}};
|
|
918
|
+
* }); // throws an error
|
|
919
|
+
* await waitUntil.hasValue(child, () => [child]); // returns `[child]`;
|
|
920
|
+
* ```
|
|
921
|
+
*
|
|
922
|
+
* @returns The callback output once it passes.
|
|
923
|
+
* @throws {@link AssertionError} On timeout.
|
|
924
|
+
* @see
|
|
925
|
+
* - {@link waitUntil.lacksValue} : the opposite assertion.
|
|
926
|
+
* - {@link waitUntil.hasValues} : the multi-value assertion.
|
|
927
|
+
*/
|
|
928
|
+
hasValue: typeof autoGuardSymbol;
|
|
929
|
+
/**
|
|
930
|
+
* Repeatedly calls a callback until its output is an object/array parent does _not_ include
|
|
931
|
+
* a child value through reference equality. Once the callback output passes, it is
|
|
932
|
+
* returned. If the attempts time out, an error is thrown.
|
|
933
|
+
*
|
|
934
|
+
* Performs no type guarding.
|
|
935
|
+
*
|
|
936
|
+
* @example
|
|
937
|
+
*
|
|
938
|
+
* ```ts
|
|
939
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
940
|
+
*
|
|
941
|
+
* const child = {a: 'a'};
|
|
942
|
+
*
|
|
943
|
+
* await waitUntil.lacksValue(child, () => {
|
|
944
|
+
* return {child};
|
|
945
|
+
* }); // throws an error
|
|
946
|
+
* await waitUntil.lacksValue(child, () => {
|
|
947
|
+
* return {child: {a: 'a'}};
|
|
948
|
+
* }); // returns `{child: {a: 'a'}}`;
|
|
949
|
+
* await waitUntil.lacksValue(child, () => [child]); // throws an error
|
|
950
|
+
* ```
|
|
951
|
+
*
|
|
952
|
+
* @returns The callback output once it passes.
|
|
953
|
+
* @throws {@link AssertionError} On timeout.
|
|
954
|
+
* @see
|
|
955
|
+
* - {@link waitUntil.hasValue} : the opposite assertion.
|
|
956
|
+
* - {@link waitUntil.lacksValues} : the multi-value assertion.
|
|
957
|
+
*/
|
|
958
|
+
lacksValue: typeof autoGuardSymbol;
|
|
959
|
+
/**
|
|
960
|
+
* Repeatedly calls a callback until its output is an object/array parent includes all child
|
|
961
|
+
* values through reference equality. Once the callback output passes, it is returned. If
|
|
962
|
+
* the attempts time out, an error is thrown.
|
|
963
|
+
*
|
|
964
|
+
* Performs no type guarding.
|
|
965
|
+
*
|
|
966
|
+
* @example
|
|
967
|
+
*
|
|
968
|
+
* ```ts
|
|
969
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
970
|
+
*
|
|
971
|
+
* const child = {a: 'a'};
|
|
972
|
+
* const child2 = {b: 'b'};
|
|
973
|
+
*
|
|
974
|
+
* await waitUntil.hasValues(
|
|
975
|
+
* [
|
|
976
|
+
* child,
|
|
977
|
+
* child2,
|
|
978
|
+
* ],
|
|
979
|
+
* () => {
|
|
980
|
+
* return {child, child2};
|
|
981
|
+
* },
|
|
982
|
+
* ); // returns `{child, child2}`;
|
|
983
|
+
* await waitUntil.hasValues(
|
|
984
|
+
* [
|
|
985
|
+
* child,
|
|
986
|
+
* child2,
|
|
987
|
+
* ],
|
|
988
|
+
* () => {
|
|
989
|
+
* return {child: {a: 'a'}, child2};
|
|
990
|
+
* },
|
|
991
|
+
* ); // throws an error
|
|
992
|
+
* await waitUntil.hasValues(
|
|
993
|
+
* [
|
|
994
|
+
* child,
|
|
995
|
+
* child2,
|
|
996
|
+
* ],
|
|
997
|
+
* () => [child],
|
|
998
|
+
* ); // returns `[child]`;
|
|
999
|
+
* ```
|
|
1000
|
+
*
|
|
1001
|
+
* @returns The callback output once it passes.
|
|
1002
|
+
* @throws {@link AssertionError} On timeout.
|
|
1003
|
+
* @see
|
|
1004
|
+
* - {@link waitUntil.lacksValues} : the opposite assertion.
|
|
1005
|
+
* - {@link waitUntil.hasValue} : the single-value assertion.
|
|
1006
|
+
*/
|
|
1007
|
+
hasValues: typeof autoGuardSymbol;
|
|
1008
|
+
/**
|
|
1009
|
+
* Repeatedly calls a callback until its output is an object/array parent includes none of
|
|
1010
|
+
* the provided child values through reference equality. Once the callback output passes, it
|
|
1011
|
+
* is returned. If the attempts time out, an error is thrown.
|
|
1012
|
+
*
|
|
1013
|
+
* Performs no type guarding.
|
|
1014
|
+
*
|
|
1015
|
+
* @example
|
|
1016
|
+
*
|
|
1017
|
+
* ```ts
|
|
1018
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1019
|
+
*
|
|
1020
|
+
* const child = {a: 'a'};
|
|
1021
|
+
* const child2 = {b: 'b'};
|
|
1022
|
+
*
|
|
1023
|
+
* await waitUntil.lacksValues(
|
|
1024
|
+
* [
|
|
1025
|
+
* child,
|
|
1026
|
+
* child2,
|
|
1027
|
+
* ],
|
|
1028
|
+
* () => {
|
|
1029
|
+
* return {};
|
|
1030
|
+
* },
|
|
1031
|
+
* ); // returns `{}`;
|
|
1032
|
+
* await waitUntil.lacksValues(
|
|
1033
|
+
* [
|
|
1034
|
+
* child,
|
|
1035
|
+
* child2,
|
|
1036
|
+
* ],
|
|
1037
|
+
* () => {
|
|
1038
|
+
* return {child, child2};
|
|
1039
|
+
* },
|
|
1040
|
+
* ); // throws an error
|
|
1041
|
+
* await waitUntil.lacksValues(
|
|
1042
|
+
* [
|
|
1043
|
+
* child,
|
|
1044
|
+
* child2,
|
|
1045
|
+
* ],
|
|
1046
|
+
* () => {
|
|
1047
|
+
* return {child: {a: 'a'}, child2};
|
|
1048
|
+
* },
|
|
1049
|
+
* ); // throws an error
|
|
1050
|
+
* ```
|
|
1051
|
+
*
|
|
1052
|
+
* @returns The callback output once it passes.
|
|
1053
|
+
* @throws {@link AssertionError} On timeout.
|
|
1054
|
+
* @see
|
|
1055
|
+
* - {@link waitUntil.lacksValues} : the opposite assertion.
|
|
1056
|
+
* - {@link waitUntil.hasValue} : the single-value assertion.
|
|
1057
|
+
*/
|
|
1058
|
+
lacksValues: typeof autoGuardSymbol;
|
|
1059
|
+
/**
|
|
1060
|
+
* Repeatedly calls a callback until its output is child value is contained within a parent
|
|
1061
|
+
* object, array, or string through reference equality. Once the callback output passes, it
|
|
1062
|
+
* is returned. If the attempts time out, an error is thrown.
|
|
1063
|
+
*
|
|
1064
|
+
* Type guards the child when possible.
|
|
1065
|
+
*
|
|
1066
|
+
* @example
|
|
1067
|
+
*
|
|
1068
|
+
* ```ts
|
|
1069
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1070
|
+
*
|
|
1071
|
+
* const child = {a: 'a'};
|
|
1072
|
+
*
|
|
1073
|
+
* await waitUntil.isIn({child}, () => child); // returns `child`
|
|
1074
|
+
* await waitUntil.isIn('ab', () => 'a'); // returns `'a'`
|
|
1075
|
+
* await waitUntil.isIn(child, () => [child]); // returns `child`
|
|
1076
|
+
*
|
|
1077
|
+
* await waitUntil.isIn({child: {a: 'a'}}, () => child); // throws an error
|
|
1078
|
+
* await waitUntil.isIn('bc', () => 'a'); // throws an error
|
|
1079
|
+
* ```
|
|
1080
|
+
*
|
|
1081
|
+
* @returns The callback output once it passes.
|
|
1082
|
+
* @throws {@link AssertionError} On timeout.
|
|
1083
|
+
* @see
|
|
1084
|
+
* - {@link waitUntil.isNotIn} : the opposite assertion.
|
|
1085
|
+
*/
|
|
100
1086
|
isIn: <const Child, const Parent>(parent: Parent, callback: () => MaybePromise<Child>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<NarrowToExpected<Child, Values<Parent>>>;
|
|
1087
|
+
/**
|
|
1088
|
+
* Repeatedly calls a callback until its output is child value is _not_ contained within a
|
|
1089
|
+
* parent object, array, or string through reference equality. Once the callback output
|
|
1090
|
+
* passes, it is returned. If the attempts time out, an error is thrown.
|
|
1091
|
+
*
|
|
1092
|
+
* Type guards the child when possible.
|
|
1093
|
+
*
|
|
1094
|
+
* @example
|
|
1095
|
+
*
|
|
1096
|
+
* ```ts
|
|
1097
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1098
|
+
*
|
|
1099
|
+
* const child = {a: 'a'};
|
|
1100
|
+
*
|
|
1101
|
+
* await waitUntil.isNotIn({child}, () => child); // throws an error
|
|
1102
|
+
* await waitUntil.isNotIn('ab', () => 'a'); // throws an error
|
|
1103
|
+
* await waitUntil.isNotIn([child], () => child); // throws an error
|
|
1104
|
+
*
|
|
1105
|
+
* await waitUntil.isNotIn({child: {a: 'a'}}, () => child); // returns `child`;
|
|
1106
|
+
* await waitUntil.isNotIn('bc', () => 'a'); // returns `'a'`;
|
|
1107
|
+
* ```
|
|
1108
|
+
*
|
|
1109
|
+
* @returns The callback output once it passes.
|
|
1110
|
+
* @throws {@link AssertionError} On timeout.
|
|
1111
|
+
* @see
|
|
1112
|
+
* - {@link waitUntil.isIn} : the opposite assertion.
|
|
1113
|
+
*/
|
|
101
1114
|
isNotIn: <const Child, const Parent>(parent: Parent, callback: () => MaybePromise<Child>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Child, Values<Parent>>>;
|
|
1115
|
+
/**
|
|
1116
|
+
* Repeatedly calls a callback until its output is a value is empty. Supports strings, Maps,
|
|
1117
|
+
* Sets, objects, and arrays. Once the callback output passes, it is returned. If the
|
|
1118
|
+
* attempts time out, an error is thrown.
|
|
1119
|
+
*
|
|
1120
|
+
* Type guards the value.
|
|
1121
|
+
*
|
|
1122
|
+
* @example
|
|
1123
|
+
*
|
|
1124
|
+
* ```ts
|
|
1125
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1126
|
+
*
|
|
1127
|
+
* await waitUntil.isEmpty(() => {
|
|
1128
|
+
* return {};
|
|
1129
|
+
* }); // returns `{}`;
|
|
1130
|
+
* await waitUntil.isEmpty(() => ''); // returns `''`;
|
|
1131
|
+
* await waitUntil.isEmpty(() => []); // returns `[]`;
|
|
1132
|
+
*
|
|
1133
|
+
* await waitUntil.isEmpty(() => 'a'); // throws an error
|
|
1134
|
+
* await waitUntil.isEmpty(() => {
|
|
1135
|
+
* return {a: 'a'};
|
|
1136
|
+
* }); // throws an error
|
|
1137
|
+
* ```
|
|
1138
|
+
*
|
|
1139
|
+
* @returns The callback output once it passes.
|
|
1140
|
+
* @throws {@link AssertionError} On timeout.
|
|
1141
|
+
* @see
|
|
1142
|
+
* - {@link waitUntil.isNotEmpty} : the opposite assertion.
|
|
1143
|
+
*/
|
|
102
1144
|
isEmpty: <const Actual extends CanBeEmpty>(callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<NarrowToActual<Actual, Empty>>;
|
|
1145
|
+
/**
|
|
1146
|
+
* Repeatedly calls a callback until its output is a value is _not_ empty. Supports strings,
|
|
1147
|
+
* Maps, Sets, objects, and arrays. Once the callback output passes, it is returned. If the
|
|
1148
|
+
* attempts time out, an error is thrown.
|
|
1149
|
+
*
|
|
1150
|
+
* Type guards the value.
|
|
1151
|
+
*
|
|
1152
|
+
* @example
|
|
1153
|
+
*
|
|
1154
|
+
* ```ts
|
|
1155
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1156
|
+
*
|
|
1157
|
+
* await waitUntil.isNotEmpty(() => {
|
|
1158
|
+
* return {};
|
|
1159
|
+
* }); // throws an error
|
|
1160
|
+
* await waitUntil.isNotEmpty(() => ''); // throws an error
|
|
1161
|
+
* await waitUntil.isNotEmpty(() => []); // throws an error
|
|
1162
|
+
*
|
|
1163
|
+
* await waitUntil.isNotEmpty(() => 'a'); // returns `'a'`;
|
|
1164
|
+
* await waitUntil.isNotEmpty(() => {
|
|
1165
|
+
* return {a: 'a'};
|
|
1166
|
+
* }); // returns `{a: 'a'}`;
|
|
1167
|
+
* ```
|
|
1168
|
+
*
|
|
1169
|
+
* @returns The callback output once it passes.
|
|
1170
|
+
* @throws {@link AssertionError} On timeout.
|
|
1171
|
+
* @see
|
|
1172
|
+
* - {@link waitUntil.isEmpty} : the opposite assertion.
|
|
1173
|
+
*/
|
|
103
1174
|
isNotEmpty: <const Actual extends CanBeEmpty>(callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, Empty>>;
|
|
104
1175
|
};
|
|
105
1176
|
};
|