@augment-vir/assert 30.0.0 → 30.0.1
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 +17 -4
|
@@ -22,34 +22,406 @@ declare function checkWrapIsLengthExactly<Actual extends string | AnyObject>(act
|
|
|
22
22
|
declare function waitUntilIsLengthExactly<Element, Length extends number>(length: Length, callback: () => MaybePromise<ReadonlyArray<Element | undefined>>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined): Promise<Tuple<Element, Length>>;
|
|
23
23
|
declare function waitUntilIsLengthExactly<Actual extends string | AnyObject>(length: number, callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined): Promise<Actual>;
|
|
24
24
|
export declare const lengthGuards: {
|
|
25
|
-
|
|
25
|
+
assert: {
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Asserts that an array or string has at least the given length.
|
|
28
28
|
*
|
|
29
|
-
* Type guards
|
|
29
|
+
* Type guards an array into an {@link AtLeastTuple}. Performs no type guarding on a string.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* import {assert} from '@augment-vir/assert';
|
|
35
|
+
*
|
|
36
|
+
* assert.isLengthAtLeast(
|
|
37
|
+
* [
|
|
38
|
+
* 'a',
|
|
39
|
+
* 'b',
|
|
40
|
+
* 'c',
|
|
41
|
+
* ],
|
|
42
|
+
* 2,
|
|
43
|
+
* ); // passes
|
|
44
|
+
* assert.isLengthAtLeast(
|
|
45
|
+
* [
|
|
46
|
+
* 'a',
|
|
47
|
+
* 'b',
|
|
48
|
+
* 'c',
|
|
49
|
+
* ],
|
|
50
|
+
* 3,
|
|
51
|
+
* ); // passes
|
|
52
|
+
* assert.isLengthAtLeast(
|
|
53
|
+
* [
|
|
54
|
+
* 'a',
|
|
55
|
+
* 'b',
|
|
56
|
+
* ],
|
|
57
|
+
* 3,
|
|
58
|
+
* ); // fails
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @throws {@link AssertionError} If the value is less than the given length.
|
|
62
|
+
* @see
|
|
63
|
+
* - {@link assert.isLengthExactly} : the more exact assertion.
|
|
30
64
|
*/
|
|
31
65
|
isLengthAtLeast: typeof isLengthAtLeast;
|
|
32
66
|
/**
|
|
33
|
-
*
|
|
67
|
+
* Asserts that an array or string has exactly the given length.
|
|
68
|
+
*
|
|
69
|
+
* Type guards an array into a {@link Tuple}. Performs no type guarding on a string.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
*
|
|
73
|
+
* ```ts
|
|
74
|
+
* import {assert} from '@augment-vir/assert';
|
|
75
|
+
*
|
|
76
|
+
* assert.isLengthExactly(
|
|
77
|
+
* [
|
|
78
|
+
* 'a',
|
|
79
|
+
* 'b',
|
|
80
|
+
* 'c',
|
|
81
|
+
* ],
|
|
82
|
+
* 2,
|
|
83
|
+
* ); // fails
|
|
84
|
+
* assert.isLengthExactly(
|
|
85
|
+
* [
|
|
86
|
+
* 'a',
|
|
87
|
+
* 'b',
|
|
88
|
+
* 'c',
|
|
89
|
+
* ],
|
|
90
|
+
* 3,
|
|
91
|
+
* ); // passes
|
|
92
|
+
* assert.isLengthExactly(
|
|
93
|
+
* [
|
|
94
|
+
* 'a',
|
|
95
|
+
* 'b',
|
|
96
|
+
* ],
|
|
97
|
+
* 3,
|
|
98
|
+
* ); // fails
|
|
99
|
+
* ```
|
|
34
100
|
*
|
|
35
|
-
*
|
|
101
|
+
* @throws {@link AssertionError} If the value is not exactly the given length.
|
|
102
|
+
* @see
|
|
103
|
+
* - {@link assert.isLengthAtLeast} : the more flexible assertion.
|
|
36
104
|
*/
|
|
37
105
|
isLengthExactly: typeof isLengthExactly;
|
|
38
106
|
};
|
|
39
|
-
|
|
107
|
+
check: {
|
|
108
|
+
/**
|
|
109
|
+
* Checks that an array or string has at least the given length.
|
|
110
|
+
*
|
|
111
|
+
* Type guards an array into an {@link AtLeastTuple}. Performs no type guarding on a string.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
*
|
|
115
|
+
* ```ts
|
|
116
|
+
* import {check} from '@augment-vir/assert';
|
|
117
|
+
*
|
|
118
|
+
* check.isLengthAtLeast(
|
|
119
|
+
* [
|
|
120
|
+
* 'a',
|
|
121
|
+
* 'b',
|
|
122
|
+
* 'c',
|
|
123
|
+
* ],
|
|
124
|
+
* 2,
|
|
125
|
+
* ); // returns `true`
|
|
126
|
+
* check.isLengthAtLeast(
|
|
127
|
+
* [
|
|
128
|
+
* 'a',
|
|
129
|
+
* 'b',
|
|
130
|
+
* 'c',
|
|
131
|
+
* ],
|
|
132
|
+
* 3,
|
|
133
|
+
* ); // returns `true`
|
|
134
|
+
* check.isLengthAtLeast(
|
|
135
|
+
* [
|
|
136
|
+
* 'a',
|
|
137
|
+
* 'b',
|
|
138
|
+
* ],
|
|
139
|
+
* 3,
|
|
140
|
+
* ); // returns `false`
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* @see
|
|
144
|
+
* - {@link check.isLengthExactly} : the more exact check.
|
|
145
|
+
*/
|
|
40
146
|
isLengthAtLeast: typeof checkIsLengthAtLeast;
|
|
147
|
+
/**
|
|
148
|
+
* Checks that an array or string has exactly the given length.
|
|
149
|
+
*
|
|
150
|
+
* Type guards an array into a {@link Tuple}. Performs no type guarding on a string.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
*
|
|
154
|
+
* ```ts
|
|
155
|
+
* import {check} from '@augment-vir/assert';
|
|
156
|
+
*
|
|
157
|
+
* check.isLengthExactly(
|
|
158
|
+
* [
|
|
159
|
+
* 'a',
|
|
160
|
+
* 'b',
|
|
161
|
+
* 'c',
|
|
162
|
+
* ],
|
|
163
|
+
* 2,
|
|
164
|
+
* ); // fails
|
|
165
|
+
* check.isLengthExactly(
|
|
166
|
+
* [
|
|
167
|
+
* 'a',
|
|
168
|
+
* 'b',
|
|
169
|
+
* 'c',
|
|
170
|
+
* ],
|
|
171
|
+
* 3,
|
|
172
|
+
* ); // passes
|
|
173
|
+
* check.isLengthExactly(
|
|
174
|
+
* [
|
|
175
|
+
* 'a',
|
|
176
|
+
* 'b',
|
|
177
|
+
* ],
|
|
178
|
+
* 3,
|
|
179
|
+
* ); // fails
|
|
180
|
+
* ```
|
|
181
|
+
*
|
|
182
|
+
* @see
|
|
183
|
+
* - {@link check.isLengthAtLeast} : the more flexible check.
|
|
184
|
+
*/
|
|
41
185
|
isLengthExactly: typeof checkIsLengthExactly;
|
|
42
186
|
};
|
|
43
|
-
|
|
187
|
+
assertWrap: {
|
|
188
|
+
/**
|
|
189
|
+
* Asserts that an array or string has at least the given length. Returns the value if the
|
|
190
|
+
* assertion passes.
|
|
191
|
+
*
|
|
192
|
+
* Type guards an array into an {@link AtLeastTuple}. Performs no type guarding on a string.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
*
|
|
196
|
+
* ```ts
|
|
197
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
198
|
+
*
|
|
199
|
+
* assertWrap.isLengthAtLeast(
|
|
200
|
+
* [
|
|
201
|
+
* 'a',
|
|
202
|
+
* 'b',
|
|
203
|
+
* 'c',
|
|
204
|
+
* ],
|
|
205
|
+
* 2,
|
|
206
|
+
* ); // returns `['a', 'b', 'c']`
|
|
207
|
+
* assertWrap.isLengthAtLeast(
|
|
208
|
+
* [
|
|
209
|
+
* 'a',
|
|
210
|
+
* 'b',
|
|
211
|
+
* 'c',
|
|
212
|
+
* ],
|
|
213
|
+
* 3,
|
|
214
|
+
* ); // returns `['a', 'b', 'c']`
|
|
215
|
+
* assertWrap.isLengthAtLeast(
|
|
216
|
+
* [
|
|
217
|
+
* 'a',
|
|
218
|
+
* 'b',
|
|
219
|
+
* ],
|
|
220
|
+
* 3,
|
|
221
|
+
* ); // throws an error
|
|
222
|
+
* ```
|
|
223
|
+
*
|
|
224
|
+
* @returns The value if it has at least the given length.
|
|
225
|
+
* @throws {@link AssertionError} If the value is less than the given length.
|
|
226
|
+
* @see
|
|
227
|
+
* - {@link assertWrap.isLengthExactly} : the more exact assertion.
|
|
228
|
+
*/
|
|
44
229
|
isLengthAtLeast: typeof assertWrapIsLengthAtLeast;
|
|
230
|
+
/**
|
|
231
|
+
* Asserts that an array or string has exactly the given length. Returns the value if the
|
|
232
|
+
* assertion passes.
|
|
233
|
+
*
|
|
234
|
+
* Type guards an array into a {@link Tuple}. Performs no type guarding on a string.
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
*
|
|
238
|
+
* ```ts
|
|
239
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
240
|
+
*
|
|
241
|
+
* assertWrap.isLengthExactly(
|
|
242
|
+
* [
|
|
243
|
+
* 'a',
|
|
244
|
+
* 'b',
|
|
245
|
+
* 'c',
|
|
246
|
+
* ],
|
|
247
|
+
* 2,
|
|
248
|
+
* ); // throws an error
|
|
249
|
+
* assertWrap.isLengthExactly(
|
|
250
|
+
* [
|
|
251
|
+
* 'a',
|
|
252
|
+
* 'b',
|
|
253
|
+
* 'c',
|
|
254
|
+
* ],
|
|
255
|
+
* 3,
|
|
256
|
+
* ); // returns `['a', 'b', 'c']`
|
|
257
|
+
* assertWrap.isLengthExactly(
|
|
258
|
+
* [
|
|
259
|
+
* 'a',
|
|
260
|
+
* 'b',
|
|
261
|
+
* ],
|
|
262
|
+
* 3,
|
|
263
|
+
* ); // throws an error
|
|
264
|
+
* ```
|
|
265
|
+
*
|
|
266
|
+
* @returns The value if it has exactly the given length.
|
|
267
|
+
* @throws {@link AssertionError} If the value is not exactly the given length.
|
|
268
|
+
* @see
|
|
269
|
+
* - {@link assertWrap.isLengthAtLeast} : the more flexible assertion.
|
|
270
|
+
*/
|
|
45
271
|
isLengthExactly: typeof assertWrapIsLengthExactly;
|
|
46
272
|
};
|
|
47
|
-
|
|
273
|
+
checkWrap: {
|
|
274
|
+
/**
|
|
275
|
+
* Checks that an array or string has at least the given length. Returns the value if the
|
|
276
|
+
* check passes, otherwise `undefined`.
|
|
277
|
+
*
|
|
278
|
+
* Type guards an array into an {@link AtLeastTuple}. Performs no type guarding on a string.
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
*
|
|
282
|
+
* ```ts
|
|
283
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
284
|
+
*
|
|
285
|
+
* checkWrap.isLengthAtLeast(
|
|
286
|
+
* [
|
|
287
|
+
* 'a',
|
|
288
|
+
* 'b',
|
|
289
|
+
* 'c',
|
|
290
|
+
* ],
|
|
291
|
+
* 2,
|
|
292
|
+
* ); // returns `['a', 'b', 'c']`
|
|
293
|
+
* checkWrap.isLengthAtLeast(
|
|
294
|
+
* [
|
|
295
|
+
* 'a',
|
|
296
|
+
* 'b',
|
|
297
|
+
* 'c',
|
|
298
|
+
* ],
|
|
299
|
+
* 3,
|
|
300
|
+
* ); // returns `['a', 'b', 'c']`
|
|
301
|
+
* checkWrap.isLengthAtLeast(
|
|
302
|
+
* [
|
|
303
|
+
* 'a',
|
|
304
|
+
* 'b',
|
|
305
|
+
* ],
|
|
306
|
+
* 3,
|
|
307
|
+
* ); // returns `undefined`
|
|
308
|
+
* ```
|
|
309
|
+
*
|
|
310
|
+
* @returns The value if the check passes, otherwise `undefined`.
|
|
311
|
+
* @see
|
|
312
|
+
* - {@link checkWrap.isLengthExactly} : the more exact check.
|
|
313
|
+
*/
|
|
48
314
|
isLengthAtLeast: typeof checkWrapIsLengthAtLeast;
|
|
315
|
+
/**
|
|
316
|
+
* Checks that an array or string has exactly the given length. Returns the value if the
|
|
317
|
+
* check passes, otherwise `undefined`.
|
|
318
|
+
*
|
|
319
|
+
* Type guards an array into a {@link Tuple}. Performs no type guarding on a string.
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
*
|
|
323
|
+
* ```ts
|
|
324
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
325
|
+
*
|
|
326
|
+
* checkWrap.isLengthExactly(
|
|
327
|
+
* [
|
|
328
|
+
* 'a',
|
|
329
|
+
* 'b',
|
|
330
|
+
* 'c',
|
|
331
|
+
* ],
|
|
332
|
+
* 2,
|
|
333
|
+
* ); // returns `undefined`
|
|
334
|
+
* checkWrap.isLengthExactly(
|
|
335
|
+
* [
|
|
336
|
+
* 'a',
|
|
337
|
+
* 'b',
|
|
338
|
+
* 'c',
|
|
339
|
+
* ],
|
|
340
|
+
* 3,
|
|
341
|
+
* ); // returns `['a', 'b', 'c']`
|
|
342
|
+
* checkWrap.isLengthExactly(
|
|
343
|
+
* [
|
|
344
|
+
* 'a',
|
|
345
|
+
* 'b',
|
|
346
|
+
* ],
|
|
347
|
+
* 3,
|
|
348
|
+
* ); // returns `undefined`
|
|
349
|
+
* ```
|
|
350
|
+
*
|
|
351
|
+
* @returns The value if the check passes, otherwise `undefined`.
|
|
352
|
+
* @see
|
|
353
|
+
* - {@link checkWrap.isLengthAtLeast} : the more flexible check.
|
|
354
|
+
*/
|
|
49
355
|
isLengthExactly: typeof checkWrapIsLengthExactly;
|
|
50
356
|
};
|
|
51
|
-
|
|
357
|
+
waitUntil: {
|
|
358
|
+
/**
|
|
359
|
+
* Repeatedly calls a callback until its output is an array or string that has at least the
|
|
360
|
+
* given length. Once the callback output passes, it is returned. If the attempts time out,
|
|
361
|
+
* an error is thrown.
|
|
362
|
+
*
|
|
363
|
+
* Type guards an array into an {@link AtLeastTuple}. Performs no type guarding on a string.
|
|
364
|
+
*
|
|
365
|
+
* @example
|
|
366
|
+
*
|
|
367
|
+
* ```ts
|
|
368
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
369
|
+
*
|
|
370
|
+
* await waitUntil.isLengthAtLeast(2, () => [
|
|
371
|
+
* 'a',
|
|
372
|
+
* 'b',
|
|
373
|
+
* 'c',
|
|
374
|
+
* ]); // returns `['a', 'b', 'c']`
|
|
375
|
+
* await waitUntil.isLengthAtLeast(3, () => [
|
|
376
|
+
* 'a',
|
|
377
|
+
* 'b',
|
|
378
|
+
* 'c',
|
|
379
|
+
* ]); // returns `['a', 'b', 'c']`
|
|
380
|
+
* await waitUntil.isLengthAtLeast(3, () => [
|
|
381
|
+
* 'a',
|
|
382
|
+
* 'b',
|
|
383
|
+
* ]); // throws an error
|
|
384
|
+
* ```
|
|
385
|
+
*
|
|
386
|
+
* @returns The callback output once it passes.
|
|
387
|
+
* @throws {@link AssertionError} On timeout.
|
|
388
|
+
* @see
|
|
389
|
+
* - {@link waitUntil.isLengthExactly} : the more exact assertion.
|
|
390
|
+
*/
|
|
52
391
|
isLengthAtLeast: typeof waitUntilIsLengthAtLeast;
|
|
392
|
+
/**
|
|
393
|
+
* Repeatedly calls a callback until its output is an array or string that has exactly the
|
|
394
|
+
* given length. Once the callback output passes, it is returned. If the attempts time out,
|
|
395
|
+
* an error is thrown.
|
|
396
|
+
*
|
|
397
|
+
* Type guards an array into a {@link Tuple}. Performs no type guarding on a string.
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
*
|
|
401
|
+
* ```ts
|
|
402
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
403
|
+
*
|
|
404
|
+
* await waitUntil.isLengthAtLeast(2, () => [
|
|
405
|
+
* 'a',
|
|
406
|
+
* 'b',
|
|
407
|
+
* 'c',
|
|
408
|
+
* ]); // throws an error
|
|
409
|
+
* await waitUntil.isLengthAtLeast(3, () => [
|
|
410
|
+
* 'a',
|
|
411
|
+
* 'b',
|
|
412
|
+
* 'c',
|
|
413
|
+
* ]); // returns `['a', 'b', 'c']`
|
|
414
|
+
* await waitUntil.isLengthAtLeast(3, () => [
|
|
415
|
+
* 'a',
|
|
416
|
+
* 'b',
|
|
417
|
+
* ]); // throws an error
|
|
418
|
+
* ```
|
|
419
|
+
*
|
|
420
|
+
* @returns The callback output once it passes.
|
|
421
|
+
* @throws {@link AssertionError} On timeout.
|
|
422
|
+
* @see
|
|
423
|
+
* - {@link waitUntil.isLengthAtLeast} : the more flexible assertion.
|
|
424
|
+
*/
|
|
53
425
|
isLengthExactly: typeof waitUntilIsLengthExactly;
|
|
54
426
|
};
|
|
55
427
|
};
|