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