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