@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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { autoGuardSymbol } from '../guard-types/guard-override.js';
|
|
1
2
|
declare function isAbove(actual: number, expected: number, failureMessage?: string | undefined): void;
|
|
2
3
|
declare function isAtLeast(actual: number, expected: number, failureMessage?: string | undefined): void;
|
|
3
4
|
declare function isBelow(actual: number, expected: number, failureMessage?: string | undefined): void;
|
|
@@ -8,62 +9,1015 @@ declare function isInfinite(actual: number, failureMessage?: string | undefined)
|
|
|
8
9
|
declare function isApproximately(actual: number, expected: number, delta: number, failureMessage?: string | undefined): void;
|
|
9
10
|
declare function isNotApproximately(actual: number, expected: number, delta: number, failureMessage?: string | undefined): void;
|
|
10
11
|
export declare const numericGuards: {
|
|
11
|
-
|
|
12
|
+
assert: {
|
|
12
13
|
/**
|
|
13
|
-
*
|
|
14
|
+
* Asserts that a number is above the expectation (`actual > expected`).
|
|
14
15
|
*
|
|
15
16
|
* Performs no type guarding.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* import {assert} from '@augment-vir/assert';
|
|
22
|
+
*
|
|
23
|
+
* assert.isAbove(10, 5); // passes
|
|
24
|
+
* assert.isAbove(5, 5); // fails
|
|
25
|
+
* assert.isAbove(5, 10); // fails
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
29
|
+
* @see
|
|
30
|
+
* - {@link assert.isBelow} : the opposite assertion.
|
|
31
|
+
* - {@link assert.isAtLeast} : the more lenient assertion.
|
|
16
32
|
*/
|
|
17
33
|
isAbove: typeof isAbove;
|
|
18
34
|
/**
|
|
19
|
-
*
|
|
35
|
+
* Asserts that a number is at least the expectation (`actual >= expected`).
|
|
20
36
|
*
|
|
21
37
|
* Performs no type guarding.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* import {assert} from '@augment-vir/assert';
|
|
43
|
+
*
|
|
44
|
+
* assert.isAtLeast(10, 5); // passes
|
|
45
|
+
* assert.isAtLeast(5, 5); // passes
|
|
46
|
+
* assert.isAtLeast(5, 10); // fails
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
50
|
+
* @see
|
|
51
|
+
* - {@link assert.isAtMost} : the opposite assertion.
|
|
52
|
+
* - {@link assert.isAbove} : the more restrictive assertion.
|
|
22
53
|
*/
|
|
23
54
|
isAtLeast: typeof isAtLeast;
|
|
24
55
|
/**
|
|
25
|
-
*
|
|
56
|
+
* Asserts that a number is below the expectation (`actual < expected`).
|
|
26
57
|
*
|
|
27
58
|
* Performs no type guarding.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
*
|
|
62
|
+
* ```ts
|
|
63
|
+
* import {assert} from '@augment-vir/assert';
|
|
64
|
+
*
|
|
65
|
+
* assert.isBelow(10, 5); // fails
|
|
66
|
+
* assert.isBelow(5, 5); // fails
|
|
67
|
+
* assert.isBelow(5, 10); // passes
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
71
|
+
* @see
|
|
72
|
+
* - {@link assert.isAbove} : the opposite assertion.
|
|
73
|
+
* - {@link assert.isAtMost} : the more lenient assertion.
|
|
28
74
|
*/
|
|
29
75
|
isBelow: typeof isBelow;
|
|
30
76
|
/**
|
|
31
|
-
*
|
|
77
|
+
* Asserts that a number is at most the expectation (`actual <= expected`).
|
|
32
78
|
*
|
|
33
79
|
* Performs no type guarding.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
*
|
|
83
|
+
* ```ts
|
|
84
|
+
* import {assert} from '@augment-vir/assert';
|
|
85
|
+
*
|
|
86
|
+
* assert.isAtMost(10, 5); // fails
|
|
87
|
+
* assert.isAtMost(5, 5); // passes
|
|
88
|
+
* assert.isAtMost(5, 10); // passes
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
92
|
+
* @see
|
|
93
|
+
* - {@link assert.isAtLeast} : the opposite assertion.
|
|
94
|
+
* - {@link assert.isBelow} : the more restrictive assertion.
|
|
34
95
|
*/
|
|
35
96
|
isAtMost: typeof isAtMost;
|
|
36
97
|
/**
|
|
37
|
-
*
|
|
38
|
-
* [`NaN`](https://developer.mozilla.org/
|
|
98
|
+
* Asserts that a number is
|
|
99
|
+
* [`NaN`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NaN).
|
|
39
100
|
*
|
|
40
101
|
* Performs no type guarding.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
*
|
|
105
|
+
* ```ts
|
|
106
|
+
* import {assert} from '@augment-vir/assert';
|
|
107
|
+
*
|
|
108
|
+
* assert.isNaN(10); // fails
|
|
109
|
+
* assert.isNaN(parseInt('invalid')); // passes
|
|
110
|
+
* assert.isNaN(Infinity); // fails
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
114
|
+
* @see
|
|
115
|
+
* - {@link assert.isNumber} : can be used as the opposite assertion.
|
|
41
116
|
*/
|
|
42
117
|
isNaN: typeof isNaNGuard;
|
|
43
118
|
/**
|
|
44
|
-
*
|
|
119
|
+
* Asserts that a number is finite: meaning, not `NaN` and not `Infinity` or `-Infinity`.
|
|
45
120
|
*
|
|
46
121
|
* Performs no type guarding.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
*
|
|
125
|
+
* ```ts
|
|
126
|
+
* import {assert} from '@augment-vir/assert';
|
|
127
|
+
*
|
|
128
|
+
* assert.isFinite(10); // passes
|
|
129
|
+
* assert.isFinite(parseInt('invalid')); // fails
|
|
130
|
+
* assert.isFinite(Infinity); // fails
|
|
131
|
+
* assert.isFinite(-Infinity); // fails
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
135
|
+
* @see
|
|
136
|
+
* - {@link assert.isNaN} : an opposite assertion.
|
|
137
|
+
* - {@link assert.isInfinite} : an opposite assertion.
|
|
47
138
|
*/
|
|
48
139
|
isFinite: typeof isFiniteGuard;
|
|
49
140
|
/**
|
|
50
|
-
*
|
|
141
|
+
* Asserts that a number is either `Infinity` or `-Infinity`.
|
|
51
142
|
*
|
|
52
143
|
* Performs no type guarding.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
*
|
|
147
|
+
* ```ts
|
|
148
|
+
* import {assert} from '@augment-vir/assert';
|
|
149
|
+
*
|
|
150
|
+
* assert.isInfinite(10); // fails
|
|
151
|
+
* assert.isInfinite(parseInt('invalid')); // fails
|
|
152
|
+
* assert.isInfinite(Infinity); // passes
|
|
153
|
+
* assert.isInfinite(-Infinity); // passes
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
157
|
+
* @see
|
|
158
|
+
* - {@link assert.isNaN} : an opposite assertion.
|
|
159
|
+
* - {@link assert.isInfinite} : an opposite assertion.
|
|
53
160
|
*/
|
|
54
161
|
isInfinite: typeof isInfinite;
|
|
55
162
|
/**
|
|
56
|
-
*
|
|
163
|
+
* Asserts that a number is within ±`delta` of the expectation.
|
|
57
164
|
*
|
|
58
165
|
* Performs no type guarding.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
*
|
|
169
|
+
* ```ts
|
|
170
|
+
* import {assert} from '@augment-vir/assert';
|
|
171
|
+
*
|
|
172
|
+
* assert.isApproximately(10, 8, 4); // passes
|
|
173
|
+
* assert.isApproximately(10, 12, 4); // passes
|
|
174
|
+
* assert.isApproximately(10, 8, 1); // fails
|
|
175
|
+
* assert.isApproximately(10, 12, 1); // fails
|
|
176
|
+
* ```
|
|
177
|
+
*
|
|
178
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
179
|
+
* @see
|
|
180
|
+
* - {@link assert.isNotApproximately} : the opposite assertion.
|
|
59
181
|
*/
|
|
60
182
|
isApproximately: typeof isApproximately;
|
|
61
183
|
/**
|
|
62
|
-
*
|
|
184
|
+
* Asserts that a number is outside ±`delta` of the expectation.
|
|
63
185
|
*
|
|
64
186
|
* Performs no type guarding.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
*
|
|
190
|
+
* ```ts
|
|
191
|
+
* import {assert} from '@augment-vir/assert';
|
|
192
|
+
*
|
|
193
|
+
* assert.isNotApproximately(10, 8, 4); // fails
|
|
194
|
+
* assert.isNotApproximately(10, 12, 4); // fails
|
|
195
|
+
* assert.isNotApproximately(10, 8, 1); // passes
|
|
196
|
+
* assert.isNotApproximately(10, 12, 1); // passes
|
|
197
|
+
* ```
|
|
198
|
+
*
|
|
199
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
200
|
+
* @see
|
|
201
|
+
* - {@link assert.isApproximately} : the opposite assertion.
|
|
65
202
|
*/
|
|
66
203
|
isNotApproximately: typeof isNotApproximately;
|
|
67
204
|
};
|
|
205
|
+
check: {
|
|
206
|
+
/**
|
|
207
|
+
* Checks that a number is above the expectation (`actual > expected`).
|
|
208
|
+
*
|
|
209
|
+
* Performs no type guarding.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
*
|
|
213
|
+
* ```ts
|
|
214
|
+
* import {check} from '@augment-vir/assert';
|
|
215
|
+
*
|
|
216
|
+
* check.isAbove(10, 5); // returns `true`
|
|
217
|
+
* check.isAbove(5, 5); // returns `false`
|
|
218
|
+
* check.isAbove(5, 10); // returns `false`
|
|
219
|
+
* ```
|
|
220
|
+
*
|
|
221
|
+
* @see
|
|
222
|
+
* - {@link check.isBelow} : the opposite check.
|
|
223
|
+
* - {@link check.isAtLeast} : the more lenient check.
|
|
224
|
+
*/
|
|
225
|
+
isAbove: typeof autoGuardSymbol;
|
|
226
|
+
/**
|
|
227
|
+
* Checks that a number is at least the expectation (`actual >= expected`).
|
|
228
|
+
*
|
|
229
|
+
* Performs no type guarding.
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
*
|
|
233
|
+
* ```ts
|
|
234
|
+
* import {check} from '@augment-vir/assert';
|
|
235
|
+
*
|
|
236
|
+
* check.isAtLeast(10, 5); // returns `true`
|
|
237
|
+
* check.isAtLeast(5, 5); // returns `true`
|
|
238
|
+
* check.isAtLeast(5, 10); // returns `false`
|
|
239
|
+
* ```
|
|
240
|
+
*
|
|
241
|
+
* @see
|
|
242
|
+
* - {@link check.isAtMost} : the opposite check.
|
|
243
|
+
* - {@link check.isAbove} : the more restrictive check.
|
|
244
|
+
*/
|
|
245
|
+
isAtLeast: typeof autoGuardSymbol;
|
|
246
|
+
/**
|
|
247
|
+
* Checks that a number is below the expectation (`actual < expected`).
|
|
248
|
+
*
|
|
249
|
+
* Performs no type guarding.
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
*
|
|
253
|
+
* ```ts
|
|
254
|
+
* import {check} from '@augment-vir/assert';
|
|
255
|
+
*
|
|
256
|
+
* check.isBelow(10, 5); // returns `false`
|
|
257
|
+
* check.isBelow(5, 5); // returns `false`
|
|
258
|
+
* check.isBelow(5, 10); // returns `true`
|
|
259
|
+
* ```
|
|
260
|
+
*
|
|
261
|
+
* @see
|
|
262
|
+
* - {@link check.isAbove} : the opposite check.
|
|
263
|
+
* - {@link check.isAtMost} : the more lenient check.
|
|
264
|
+
*/
|
|
265
|
+
isBelow: typeof autoGuardSymbol;
|
|
266
|
+
/**
|
|
267
|
+
* Checks that a number is at most the expectation (`actual <= expected`).
|
|
268
|
+
*
|
|
269
|
+
* Performs no type guarding.
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
*
|
|
273
|
+
* ```ts
|
|
274
|
+
* import {check} from '@augment-vir/assert';
|
|
275
|
+
*
|
|
276
|
+
* check.isAtMost(10, 5); // returns `false`
|
|
277
|
+
* check.isAtMost(5, 5); // returns `true`
|
|
278
|
+
* check.isAtMost(5, 10); // returns `true`
|
|
279
|
+
* ```
|
|
280
|
+
*
|
|
281
|
+
* @see
|
|
282
|
+
* - {@link check.isAtLeast} : the opposite check.
|
|
283
|
+
* - {@link check.isBelow} : the more restrictive check.
|
|
284
|
+
*/
|
|
285
|
+
isAtMost: typeof autoGuardSymbol;
|
|
286
|
+
/**
|
|
287
|
+
* Checks that a number is
|
|
288
|
+
* [`NaN`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NaN).
|
|
289
|
+
*
|
|
290
|
+
* Performs no type guarding.
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
*
|
|
294
|
+
* ```ts
|
|
295
|
+
* import {check} from '@augment-vir/assert';
|
|
296
|
+
*
|
|
297
|
+
* check.isNaN(10); // returns `false`
|
|
298
|
+
* check.isNaN(parseInt('invalid')); // returns `true`
|
|
299
|
+
* check.isNaN(Infinity); // returns `false`
|
|
300
|
+
* ```
|
|
301
|
+
*
|
|
302
|
+
* @see
|
|
303
|
+
* - {@link check.isNumber} : can be used as the opposite check.
|
|
304
|
+
*/
|
|
305
|
+
isNaN: typeof autoGuardSymbol;
|
|
306
|
+
/**
|
|
307
|
+
* Checks that a number is finite: meaning, not `NaN` and not `Infinity` or `-Infinity`.
|
|
308
|
+
*
|
|
309
|
+
* Performs no type guarding.
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
*
|
|
313
|
+
* ```ts
|
|
314
|
+
* import {check} from '@augment-vir/assert';
|
|
315
|
+
*
|
|
316
|
+
* check.isFinite(10); // returns `true`
|
|
317
|
+
* check.isFinite(parseInt('invalid')); // returns `false`
|
|
318
|
+
* check.isFinite(Infinity); // returns `false`
|
|
319
|
+
* check.isFinite(-Infinity); // returns `false`
|
|
320
|
+
* ```
|
|
321
|
+
*
|
|
322
|
+
* @see
|
|
323
|
+
* - {@link check.isNaN} : an opposite check.
|
|
324
|
+
* - {@link check.isInfinite} : an opposite check.
|
|
325
|
+
*/
|
|
326
|
+
isFinite: typeof autoGuardSymbol;
|
|
327
|
+
/**
|
|
328
|
+
* Checks that a number is either `Infinity` or `-Infinity`.
|
|
329
|
+
*
|
|
330
|
+
* Performs no type guarding.
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
*
|
|
334
|
+
* ```ts
|
|
335
|
+
* import {check} from '@augment-vir/assert';
|
|
336
|
+
*
|
|
337
|
+
* check.isInfinite(10); // returns `false`
|
|
338
|
+
* check.isInfinite(parseInt('invalid')); // returns `false`
|
|
339
|
+
* check.isInfinite(Infinity); // returns `true`
|
|
340
|
+
* check.isInfinite(-Infinity); // returns `true`
|
|
341
|
+
* ```
|
|
342
|
+
*
|
|
343
|
+
* @see
|
|
344
|
+
* - {@link check.isNaN} : an opposite check.
|
|
345
|
+
* - {@link check.isInfinite} : an opposite check.
|
|
346
|
+
*/
|
|
347
|
+
isInfinite: typeof autoGuardSymbol;
|
|
348
|
+
/**
|
|
349
|
+
* Checks that a number is within ±`delta` of the expectation.
|
|
350
|
+
*
|
|
351
|
+
* Performs no type guarding.
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
*
|
|
355
|
+
* ```ts
|
|
356
|
+
* import {check} from '@augment-vir/assert';
|
|
357
|
+
*
|
|
358
|
+
* check.isApproximately(10, 8, 4); // returns `true`
|
|
359
|
+
* check.isApproximately(10, 12, 4); // returns `true`
|
|
360
|
+
* check.isApproximately(10, 8, 1); // returns `false`
|
|
361
|
+
* check.isApproximately(10, 12, 1); // returns `false`
|
|
362
|
+
* ```
|
|
363
|
+
*
|
|
364
|
+
* @see
|
|
365
|
+
* - {@link check.isNotApproximately} : the opposite check.
|
|
366
|
+
*/
|
|
367
|
+
isApproximately: typeof autoGuardSymbol;
|
|
368
|
+
/**
|
|
369
|
+
* Checks that a number is outside ±`delta` of the expectation.
|
|
370
|
+
*
|
|
371
|
+
* Performs no type guarding.
|
|
372
|
+
*
|
|
373
|
+
* @example
|
|
374
|
+
*
|
|
375
|
+
* ```ts
|
|
376
|
+
* import {check} from '@augment-vir/assert';
|
|
377
|
+
*
|
|
378
|
+
* check.isNotApproximately(10, 8, 4); // returns `false`
|
|
379
|
+
* check.isNotApproximately(10, 12, 4); // returns `false`
|
|
380
|
+
* check.isNotApproximately(10, 8, 1); // returns `true`
|
|
381
|
+
* check.isNotApproximately(10, 12, 1); // returns `true`
|
|
382
|
+
* ```
|
|
383
|
+
*
|
|
384
|
+
* @see
|
|
385
|
+
* - {@link check.isApproximately} : the opposite check.
|
|
386
|
+
*/
|
|
387
|
+
isNotApproximately: typeof autoGuardSymbol;
|
|
388
|
+
};
|
|
389
|
+
assertWrap: {
|
|
390
|
+
/**
|
|
391
|
+
* Asserts that a number is above the expectation (`actual > expected`). Returns the number
|
|
392
|
+
* if the assertion passes.
|
|
393
|
+
*
|
|
394
|
+
* Performs no type guarding.
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
*
|
|
398
|
+
* ```ts
|
|
399
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
400
|
+
*
|
|
401
|
+
* assertWrap.isAbove(10, 5); // returns `10`
|
|
402
|
+
* assertWrap.isAbove(5, 5); // throws an error
|
|
403
|
+
* assertWrap.isAbove(5, 10); // throws an error
|
|
404
|
+
* ```
|
|
405
|
+
*
|
|
406
|
+
* @returns The value if the assertion passes.
|
|
407
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
408
|
+
* @see
|
|
409
|
+
* - {@link assertWrap.isBelow} : the opposite assertion.
|
|
410
|
+
* - {@link assertWrap.isAtLeast} : the more lenient assertion.
|
|
411
|
+
*/
|
|
412
|
+
isAbove: typeof autoGuardSymbol;
|
|
413
|
+
/**
|
|
414
|
+
* Asserts that a number is at least the expectation (`actual >= expected`). Returns the
|
|
415
|
+
* number if the assertion passes.
|
|
416
|
+
*
|
|
417
|
+
* Performs no type guarding.
|
|
418
|
+
*
|
|
419
|
+
* @example
|
|
420
|
+
*
|
|
421
|
+
* ```ts
|
|
422
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
423
|
+
*
|
|
424
|
+
* assertWrap.isAtLeast(10, 5); // returns `10`
|
|
425
|
+
* assertWrap.isAtLeast(5, 5); // returns `5`
|
|
426
|
+
* assertWrap.isAtLeast(5, 10); // throws an error
|
|
427
|
+
* ```
|
|
428
|
+
*
|
|
429
|
+
* @returns The value if the assertion passes.
|
|
430
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
431
|
+
* @see
|
|
432
|
+
* - {@link assertWrap.isAtMost} : the opposite assertion.
|
|
433
|
+
* - {@link assertWrap.isAbove} : the more restrictive assertion.
|
|
434
|
+
*/
|
|
435
|
+
isAtLeast: typeof autoGuardSymbol;
|
|
436
|
+
/**
|
|
437
|
+
* Asserts that a number is below the expectation (`actual < expected`). Returns the number
|
|
438
|
+
* if the assertion passes.
|
|
439
|
+
*
|
|
440
|
+
* Performs no type guarding.
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
*
|
|
444
|
+
* ```ts
|
|
445
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
446
|
+
*
|
|
447
|
+
* assertWrap.isBelow(10, 5); // throws an error
|
|
448
|
+
* assertWrap.isBelow(5, 5); // throws an error
|
|
449
|
+
* assertWrap.isBelow(5, 10); // returns `5`
|
|
450
|
+
* ```
|
|
451
|
+
*
|
|
452
|
+
* @returns The value if the assertion passes.
|
|
453
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
454
|
+
* @see
|
|
455
|
+
* - {@link assertWrap.isAbove} : the opposite assertion.
|
|
456
|
+
* - {@link assertWrap.isAtMost} : the more lenient assertion.
|
|
457
|
+
*/
|
|
458
|
+
isBelow: typeof autoGuardSymbol;
|
|
459
|
+
/**
|
|
460
|
+
* Asserts that a number is at most the expectation (`actual <= expected`). Returns the
|
|
461
|
+
* number if the assertion passes.
|
|
462
|
+
*
|
|
463
|
+
* Performs no type guarding.
|
|
464
|
+
*
|
|
465
|
+
* @example
|
|
466
|
+
*
|
|
467
|
+
* ```ts
|
|
468
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
469
|
+
*
|
|
470
|
+
* assertWrap.isAtMost(10, 5); // throws an error
|
|
471
|
+
* assertWrap.isAtMost(5, 5); // returns `5`
|
|
472
|
+
* assertWrap.isAtMost(5, 10); // returns `5`
|
|
473
|
+
* ```
|
|
474
|
+
*
|
|
475
|
+
* @returns The value if the assertion passes.
|
|
476
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
477
|
+
* @see
|
|
478
|
+
* - {@link assertWrap.isAtLeast} : the opposite assertion.
|
|
479
|
+
* - {@link assertWrap.isBelow} : the more restrictive assertion.
|
|
480
|
+
*/
|
|
481
|
+
isAtMost: typeof autoGuardSymbol;
|
|
482
|
+
/**
|
|
483
|
+
* Asserts that a number is
|
|
484
|
+
* [`NaN`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NaN).
|
|
485
|
+
* Returns the number if the assertion passes.
|
|
486
|
+
*
|
|
487
|
+
* Performs no type guarding.
|
|
488
|
+
*
|
|
489
|
+
* @example
|
|
490
|
+
*
|
|
491
|
+
* ```ts
|
|
492
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
493
|
+
*
|
|
494
|
+
* assertWrap.isNaN(10); // throws an error
|
|
495
|
+
* assertWrap.isNaN(parseInt('invalid')); // returns `NaN`
|
|
496
|
+
* assertWrap.isNaN(Infinity); // throws an error
|
|
497
|
+
* ```
|
|
498
|
+
*
|
|
499
|
+
* @returns The value if the assertion passes.
|
|
500
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
501
|
+
* @see
|
|
502
|
+
* - {@link assertWrap.isNumber} : can be used as the opposite assertion.
|
|
503
|
+
*/
|
|
504
|
+
isNaN: typeof autoGuardSymbol;
|
|
505
|
+
/**
|
|
506
|
+
* Asserts that a number is finite: meaning, not `NaN` and not `Infinity` or `-Infinity`.
|
|
507
|
+
* Returns the number if the assertion passes.
|
|
508
|
+
*
|
|
509
|
+
* Performs no type guarding.
|
|
510
|
+
*
|
|
511
|
+
* @example
|
|
512
|
+
*
|
|
513
|
+
* ```ts
|
|
514
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
515
|
+
*
|
|
516
|
+
* assertWrap.isFinite(10); // returns `10`
|
|
517
|
+
* assertWrap.isFinite(parseInt('invalid')); // throws an error
|
|
518
|
+
* assertWrap.isFinite(Infinity); // throws an error
|
|
519
|
+
* assertWrap.isFinite(-Infinity); // throws an error
|
|
520
|
+
* ```
|
|
521
|
+
*
|
|
522
|
+
* @returns The value if the assertion passes.
|
|
523
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
524
|
+
* @see
|
|
525
|
+
* - {@link assertWrap.isNaN} : an opposite assertion.
|
|
526
|
+
* - {@link assertWrap.isInfinite} : an opposite assertion.
|
|
527
|
+
*/
|
|
528
|
+
isFinite: typeof autoGuardSymbol;
|
|
529
|
+
/**
|
|
530
|
+
* Asserts that a number is either `Infinity` or `-Infinity`. Returns the number if the
|
|
531
|
+
* assertion passes.
|
|
532
|
+
*
|
|
533
|
+
* Performs no type guarding.
|
|
534
|
+
*
|
|
535
|
+
* @example
|
|
536
|
+
*
|
|
537
|
+
* ```ts
|
|
538
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
539
|
+
*
|
|
540
|
+
* assertWrap.isInfinite(10); // throws an error
|
|
541
|
+
* assertWrap.isInfinite(parseInt('invalid')); // throws an error
|
|
542
|
+
* assertWrap.isInfinite(Infinity); // returns `Infinity`
|
|
543
|
+
* assertWrap.isInfinite(-Infinity); // returns `-Infinity`
|
|
544
|
+
* ```
|
|
545
|
+
*
|
|
546
|
+
* @returns The value if the assertion passes.
|
|
547
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
548
|
+
* @see
|
|
549
|
+
* - {@link assertWrap.isNaN} : an opposite assertion.
|
|
550
|
+
* - {@link assertWrap.isInfinite} : an opposite assertion.
|
|
551
|
+
*/
|
|
552
|
+
isInfinite: typeof autoGuardSymbol;
|
|
553
|
+
/**
|
|
554
|
+
* Asserts that a number is within ±`delta` of the expectation. Returns the number if the
|
|
555
|
+
* assertion passes.
|
|
556
|
+
*
|
|
557
|
+
* Performs no type guarding.
|
|
558
|
+
*
|
|
559
|
+
* @example
|
|
560
|
+
*
|
|
561
|
+
* ```ts
|
|
562
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
563
|
+
*
|
|
564
|
+
* assertWrap.isApproximately(10, 8, 4); // returns `10`
|
|
565
|
+
* assertWrap.isApproximately(10, 12, 4); // returns `10`
|
|
566
|
+
* assertWrap.isApproximately(10, 8, 1); // throws an error
|
|
567
|
+
* assertWrap.isApproximately(10, 12, 1); // throws an error
|
|
568
|
+
* ```
|
|
569
|
+
*
|
|
570
|
+
* @returns The value if the assertion passes.
|
|
571
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
572
|
+
* @see
|
|
573
|
+
* - {@link assertWrap.isNotApproximately} : the opposite assertion.
|
|
574
|
+
*/
|
|
575
|
+
isApproximately: typeof autoGuardSymbol;
|
|
576
|
+
/**
|
|
577
|
+
* Asserts that a number is outside ±`delta` of the expectation. Returns the number if the
|
|
578
|
+
* assertion passes.
|
|
579
|
+
*
|
|
580
|
+
* Performs no type guarding.
|
|
581
|
+
*
|
|
582
|
+
* @example
|
|
583
|
+
*
|
|
584
|
+
* ```ts
|
|
585
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
586
|
+
*
|
|
587
|
+
* assertWrap.isNotApproximately(10, 8, 4); // throws an error
|
|
588
|
+
* assertWrap.isNotApproximately(10, 12, 4); // throws an error
|
|
589
|
+
* assertWrap.isNotApproximately(10, 8, 1); // returns `10`
|
|
590
|
+
* assertWrap.isNotApproximately(10, 12, 1); // returns `10`
|
|
591
|
+
* ```
|
|
592
|
+
*
|
|
593
|
+
* @returns The value if the assertion passes.
|
|
594
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
595
|
+
* @see
|
|
596
|
+
* - {@link assertWrap.isApproximately} : the opposite assertion.
|
|
597
|
+
*/
|
|
598
|
+
isNotApproximately: typeof autoGuardSymbol;
|
|
599
|
+
};
|
|
600
|
+
checkWrap: {
|
|
601
|
+
/**
|
|
602
|
+
* Checks that a number is above the expectation (`actual > expected`). Returns the number
|
|
603
|
+
* if the check passes, otherwise `undefined`.
|
|
604
|
+
*
|
|
605
|
+
* Performs no type guarding.
|
|
606
|
+
*
|
|
607
|
+
* @example
|
|
608
|
+
*
|
|
609
|
+
* ```ts
|
|
610
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
611
|
+
*
|
|
612
|
+
* checkWrap.isAbove(10, 5); // returns `10`
|
|
613
|
+
* checkWrap.isAbove(5, 5); // returns `undefined`
|
|
614
|
+
* checkWrap.isAbove(5, 10); // returns `undefined`
|
|
615
|
+
* ```
|
|
616
|
+
*
|
|
617
|
+
* @returns The value if the check passes, otherwise `undefined`.
|
|
618
|
+
* @see
|
|
619
|
+
* - {@link checkWrap.isBelow} : the opposite check.
|
|
620
|
+
* - {@link checkWrap.isAtLeast} : the more lenient check.
|
|
621
|
+
*/
|
|
622
|
+
isAbove: typeof autoGuardSymbol;
|
|
623
|
+
/**
|
|
624
|
+
* Checks that a number is at least the expectation (`actual >= expected`). Returns the
|
|
625
|
+
* number if the check passes, otherwise `undefined`.
|
|
626
|
+
*
|
|
627
|
+
* Performs no type guarding.
|
|
628
|
+
*
|
|
629
|
+
* @example
|
|
630
|
+
*
|
|
631
|
+
* ```ts
|
|
632
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
633
|
+
*
|
|
634
|
+
* checkWrap.isAtLeast(10, 5); // returns `10`
|
|
635
|
+
* checkWrap.isAtLeast(5, 5); // returns `5`
|
|
636
|
+
* checkWrap.isAtLeast(5, 10); // returns `undefined`
|
|
637
|
+
* ```
|
|
638
|
+
*
|
|
639
|
+
* @returns The value if the check passes, otherwise `undefined`.
|
|
640
|
+
* @see
|
|
641
|
+
* - {@link checkWrap.isAtMost} : the opposite check.
|
|
642
|
+
* - {@link checkWrap.isAbove} : the more restrictive check.
|
|
643
|
+
*/
|
|
644
|
+
isAtLeast: typeof autoGuardSymbol;
|
|
645
|
+
/**
|
|
646
|
+
* Checks that a number is below the expectation (`actual < expected`). Returns the number
|
|
647
|
+
* if the check passes, otherwise `undefined`.
|
|
648
|
+
*
|
|
649
|
+
* Performs no type guarding.
|
|
650
|
+
*
|
|
651
|
+
* @example
|
|
652
|
+
*
|
|
653
|
+
* ```ts
|
|
654
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
655
|
+
*
|
|
656
|
+
* checkWrap.isBelow(10, 5); // returns `undefined`
|
|
657
|
+
* checkWrap.isBelow(5, 5); // returns `undefined`
|
|
658
|
+
* checkWrap.isBelow(5, 10); // returns `5`
|
|
659
|
+
* ```
|
|
660
|
+
*
|
|
661
|
+
* @returns The value if the check passes, otherwise `undefined`.
|
|
662
|
+
* @see
|
|
663
|
+
* - {@link checkWrap.isAbove} : the opposite check.
|
|
664
|
+
* - {@link checkWrap.isAtMost} : the more lenient check.
|
|
665
|
+
*/
|
|
666
|
+
isBelow: typeof autoGuardSymbol;
|
|
667
|
+
/**
|
|
668
|
+
* Checks that a number is at most the expectation (`actual <= expected`). Returns the
|
|
669
|
+
* number if the check passes, otherwise `undefined`.
|
|
670
|
+
*
|
|
671
|
+
* Performs no type guarding.
|
|
672
|
+
*
|
|
673
|
+
* @example
|
|
674
|
+
*
|
|
675
|
+
* ```ts
|
|
676
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
677
|
+
*
|
|
678
|
+
* checkWrap.isAtMost(10, 5); // returns `undefined`
|
|
679
|
+
* checkWrap.isAtMost(5, 5); // returns `5`
|
|
680
|
+
* checkWrap.isAtMost(5, 10); // returns `5`
|
|
681
|
+
* ```
|
|
682
|
+
*
|
|
683
|
+
* @returns The value if the check passes, otherwise `undefined`.
|
|
684
|
+
* @see
|
|
685
|
+
* - {@link checkWrap.isAtLeast} : the opposite check.
|
|
686
|
+
* - {@link checkWrap.isBelow} : the more restrictive check.
|
|
687
|
+
*/
|
|
688
|
+
isAtMost: typeof autoGuardSymbol;
|
|
689
|
+
/**
|
|
690
|
+
* Checks that a number is
|
|
691
|
+
* [`NaN`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NaN).
|
|
692
|
+
* Returns the number if the check passes, otherwise `undefined`.
|
|
693
|
+
*
|
|
694
|
+
* Performs no type guarding.
|
|
695
|
+
*
|
|
696
|
+
* @example
|
|
697
|
+
*
|
|
698
|
+
* ```ts
|
|
699
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
700
|
+
*
|
|
701
|
+
* checkWrap.isNaN(10); // returns `undefined`
|
|
702
|
+
* checkWrap.isNaN(parseInt('invalid')); // returns `NaN`
|
|
703
|
+
* checkWrap.isNaN(Infinity); // returns `undefined`
|
|
704
|
+
* ```
|
|
705
|
+
*
|
|
706
|
+
* @returns The value if the check passes, otherwise `undefined`.
|
|
707
|
+
* @see
|
|
708
|
+
* - {@link checkWrap.isNumber} : can be used as the opposite check.
|
|
709
|
+
*/
|
|
710
|
+
isNaN: typeof autoGuardSymbol;
|
|
711
|
+
/**
|
|
712
|
+
* Checks that a number is finite: meaning, not `NaN` and not `Infinity` or `-Infinity`.
|
|
713
|
+
* Returns the number if the check passes, otherwise `undefined`.
|
|
714
|
+
*
|
|
715
|
+
* Performs no type guarding.
|
|
716
|
+
*
|
|
717
|
+
* @example
|
|
718
|
+
*
|
|
719
|
+
* ```ts
|
|
720
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
721
|
+
*
|
|
722
|
+
* checkWrap.isFinite(10); // returns `10`
|
|
723
|
+
* checkWrap.isFinite(parseInt('invalid')); // returns `undefined`
|
|
724
|
+
* checkWrap.isFinite(Infinity); // returns `undefined`
|
|
725
|
+
* checkWrap.isFinite(-Infinity); // returns `undefined`
|
|
726
|
+
* ```
|
|
727
|
+
*
|
|
728
|
+
* @returns The value if the check passes, otherwise `undefined`.
|
|
729
|
+
* @see
|
|
730
|
+
* - {@link checkWrap.isNaN} : an opposite check.
|
|
731
|
+
* - {@link checkWrap.isInfinite} : an opposite check.
|
|
732
|
+
*/
|
|
733
|
+
isFinite: typeof autoGuardSymbol;
|
|
734
|
+
/**
|
|
735
|
+
* Checks that a number is either `Infinity` or `-Infinity`. Returns the number if the check
|
|
736
|
+
* passes, otherwise `undefined`.
|
|
737
|
+
*
|
|
738
|
+
* Performs no type guarding.
|
|
739
|
+
*
|
|
740
|
+
* @example
|
|
741
|
+
*
|
|
742
|
+
* ```ts
|
|
743
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
744
|
+
*
|
|
745
|
+
* checkWrap.isInfinite(10); // returns `undefined`
|
|
746
|
+
* checkWrap.isInfinite(parseInt('invalid')); // returns `undefined`
|
|
747
|
+
* checkWrap.isInfinite(Infinity); // returns `Infinity`
|
|
748
|
+
* checkWrap.isInfinite(-Infinity); // returns `-Infinity`
|
|
749
|
+
* ```
|
|
750
|
+
*
|
|
751
|
+
* @returns The value if the check passes, otherwise `undefined`.
|
|
752
|
+
* @see
|
|
753
|
+
* - {@link checkWrap.isNaN} : an opposite check.
|
|
754
|
+
* - {@link checkWrap.isInfinite} : an opposite check.
|
|
755
|
+
*/
|
|
756
|
+
isInfinite: typeof autoGuardSymbol;
|
|
757
|
+
/**
|
|
758
|
+
* Checks that a number is within ±`delta` of the expectation. Returns the number if the
|
|
759
|
+
* check passes, otherwise `undefined`.
|
|
760
|
+
*
|
|
761
|
+
* Performs no type guarding.
|
|
762
|
+
*
|
|
763
|
+
* @example
|
|
764
|
+
*
|
|
765
|
+
* ```ts
|
|
766
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
767
|
+
*
|
|
768
|
+
* checkWrap.isApproximately(10, 8, 4); // returns `10`
|
|
769
|
+
* checkWrap.isApproximately(10, 12, 4); // returns `10`
|
|
770
|
+
* checkWrap.isApproximately(10, 8, 1); // returns `undefined`
|
|
771
|
+
* checkWrap.isApproximately(10, 12, 1); // returns `undefined`
|
|
772
|
+
* ```
|
|
773
|
+
*
|
|
774
|
+
* @returns The value if the check passes, otherwise `undefined`.
|
|
775
|
+
* @see
|
|
776
|
+
* - {@link checkWrap.isNotApproximately} : the opposite check.
|
|
777
|
+
*/
|
|
778
|
+
isApproximately: typeof autoGuardSymbol;
|
|
779
|
+
/**
|
|
780
|
+
* Checks that a number is outside ±`delta` of the expectation. Returns the number if the
|
|
781
|
+
* check passes, otherwise `undefined`.
|
|
782
|
+
*
|
|
783
|
+
* Performs no type guarding.
|
|
784
|
+
*
|
|
785
|
+
* @example
|
|
786
|
+
*
|
|
787
|
+
* ```ts
|
|
788
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
789
|
+
*
|
|
790
|
+
* checkWrap.isNotApproximately(10, 8, 4); // returns `undefined`
|
|
791
|
+
* checkWrap.isNotApproximately(10, 12, 4); // returns `undefined`
|
|
792
|
+
* checkWrap.isNotApproximately(10, 8, 1); // returns `10`
|
|
793
|
+
* checkWrap.isNotApproximately(10, 12, 1); // returns `10`
|
|
794
|
+
* ```
|
|
795
|
+
*
|
|
796
|
+
* @returns The value if the check passes, otherwise `undefined`.
|
|
797
|
+
* @see
|
|
798
|
+
* - {@link checkWrap.isApproximately} : the opposite check.
|
|
799
|
+
*/
|
|
800
|
+
isNotApproximately: typeof autoGuardSymbol;
|
|
801
|
+
};
|
|
802
|
+
waitUntil: {
|
|
803
|
+
/**
|
|
804
|
+
* Repeatedly calls a callback until its output is a number that is above the expectation
|
|
805
|
+
* (`actual > expected`). Once the callback output passes, it is returned. If the attempts
|
|
806
|
+
* time out, an error is thrown.
|
|
807
|
+
*
|
|
808
|
+
* Performs no type guarding.
|
|
809
|
+
*
|
|
810
|
+
* @example
|
|
811
|
+
*
|
|
812
|
+
* ```ts
|
|
813
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
814
|
+
*
|
|
815
|
+
* await waitUntil.isAbove(5, () => 10); // returns `10`
|
|
816
|
+
* await waitUntil.isAbove(5, () => 5); // throws an error
|
|
817
|
+
* await waitUntil.isAbove(10, () => 5); // throws an error
|
|
818
|
+
* ```
|
|
819
|
+
*
|
|
820
|
+
* @returns The callback output once it passes.
|
|
821
|
+
* @throws {@link AssertionError} On timeout.
|
|
822
|
+
* @see
|
|
823
|
+
* - {@link waitUntil.isBelow} : the opposite assertion.
|
|
824
|
+
* - {@link waitUntil.isAtLeast} : the more lenient assertion.
|
|
825
|
+
*/
|
|
826
|
+
isAbove: typeof autoGuardSymbol;
|
|
827
|
+
/**
|
|
828
|
+
* Repeatedly calls a callback until its output is a number that is at least the expectation
|
|
829
|
+
* (`actual >= expected`). Once the callback output passes, it is returned. If the attempts
|
|
830
|
+
* time out, an error is thrown.
|
|
831
|
+
*
|
|
832
|
+
* Performs no type guarding.
|
|
833
|
+
*
|
|
834
|
+
* @example
|
|
835
|
+
*
|
|
836
|
+
* ```ts
|
|
837
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
838
|
+
*
|
|
839
|
+
* await waitUntil.isAtLeast(5, () => 10); // returns `10`
|
|
840
|
+
* await waitUntil.isAtLeast(5, () => 5); // returns `5`
|
|
841
|
+
* await waitUntil.isAtLeast(10, () => 5); // throws an error
|
|
842
|
+
* ```
|
|
843
|
+
*
|
|
844
|
+
* @returns The callback output once it passes.
|
|
845
|
+
* @throws {@link AssertionError} On timeout.
|
|
846
|
+
* @see
|
|
847
|
+
* - {@link waitUntil.isAtMost} : the opposite assertion.
|
|
848
|
+
* - {@link waitUntil.isAbove} : the more restrictive assertion.
|
|
849
|
+
*/
|
|
850
|
+
isAtLeast: typeof autoGuardSymbol;
|
|
851
|
+
/**
|
|
852
|
+
* Repeatedly calls a callback until its output is a number that is below the expectation
|
|
853
|
+
* (`actual < expected`). Once the callback output passes, it is returned. If the attempts
|
|
854
|
+
* time out, an error is thrown.
|
|
855
|
+
*
|
|
856
|
+
* Performs no type guarding.
|
|
857
|
+
*
|
|
858
|
+
* @example
|
|
859
|
+
*
|
|
860
|
+
* ```ts
|
|
861
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
862
|
+
*
|
|
863
|
+
* await waitUntil.isBelow(5, () => 10); // throws an error
|
|
864
|
+
* await waitUntil.isBelow(5, () => 5); // throws an error
|
|
865
|
+
* await waitUntil.isBelow(10, () => 5); // returns `5`
|
|
866
|
+
* ```
|
|
867
|
+
*
|
|
868
|
+
* @returns The callback output once it passes.
|
|
869
|
+
* @throws {@link AssertionError} On timeout.
|
|
870
|
+
* @see
|
|
871
|
+
* - {@link waitUntil.isAbove} : the opposite assertion.
|
|
872
|
+
* - {@link waitUntil.isAtMost} : the more lenient assertion.
|
|
873
|
+
*/
|
|
874
|
+
isBelow: typeof autoGuardSymbol;
|
|
875
|
+
/**
|
|
876
|
+
* Repeatedly calls a callback until its output is a number that is at most the expectation
|
|
877
|
+
* (`actual <= expected`). Once the callback output passes, it is returned. If the attempts
|
|
878
|
+
* time out, an error is thrown.
|
|
879
|
+
*
|
|
880
|
+
* Performs no type guarding.
|
|
881
|
+
*
|
|
882
|
+
* @example
|
|
883
|
+
*
|
|
884
|
+
* ```ts
|
|
885
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
886
|
+
*
|
|
887
|
+
* await waitUntil.isAtMost(5, () => 10); // throws an error
|
|
888
|
+
* await waitUntil.isAtMost(5, () => 5); // returns `5`
|
|
889
|
+
* await waitUntil.isAtMost(10, () => 5); // returns `5`
|
|
890
|
+
* ```
|
|
891
|
+
*
|
|
892
|
+
* @returns The callback output once it passes.
|
|
893
|
+
* @throws {@link AssertionError} On timeout.
|
|
894
|
+
* @see
|
|
895
|
+
* - {@link waitUntil.isAtLeast} : the opposite assertion.
|
|
896
|
+
* - {@link waitUntil.isBelow} : the more restrictive assertion.
|
|
897
|
+
*/
|
|
898
|
+
isAtMost: typeof autoGuardSymbol;
|
|
899
|
+
/**
|
|
900
|
+
* Repeatedly calls a callback until its output is a number that is
|
|
901
|
+
* [`NaN`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/NaN).
|
|
902
|
+
* Once the callback output passes, it is returned. If the attempts time out, an error is
|
|
903
|
+
* thrown.
|
|
904
|
+
*
|
|
905
|
+
* Performs no type guarding.
|
|
906
|
+
*
|
|
907
|
+
* @example
|
|
908
|
+
*
|
|
909
|
+
* ```ts
|
|
910
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
911
|
+
*
|
|
912
|
+
* await waitUntil.isNaN(() => 10); // throws an error
|
|
913
|
+
* await waitUntil.isNaN(() => parseInt('invalid')); // returns `NaN`
|
|
914
|
+
* await waitUntil.isNaN(() => Infinity); // throws an error
|
|
915
|
+
* ```
|
|
916
|
+
*
|
|
917
|
+
* @returns The callback output once it passes.
|
|
918
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
919
|
+
* @see
|
|
920
|
+
* - {@link waitUntil.isNumber} : can be used as the opposite assertion.
|
|
921
|
+
*/
|
|
922
|
+
isNaN: typeof autoGuardSymbol;
|
|
923
|
+
/**
|
|
924
|
+
* Repeatedly calls a callback until its output is a number that is finite: meaning, not
|
|
925
|
+
* `NaN` and not `Infinity` or `-Infinity`. Once the callback output passes, it is returned.
|
|
926
|
+
* If the attempts time out, an error is thrown.
|
|
927
|
+
*
|
|
928
|
+
* Performs no type guarding.
|
|
929
|
+
*
|
|
930
|
+
* @example
|
|
931
|
+
*
|
|
932
|
+
* ```ts
|
|
933
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
934
|
+
*
|
|
935
|
+
* await waitUntil.isFinite(() => 10); // returns `10`
|
|
936
|
+
* await waitUntil.isFinite(() => parseInt('invalid')); // throws an error
|
|
937
|
+
* await waitUntil.isFinite(() => Infinity); // throws an error
|
|
938
|
+
* await waitUntil.isFinite(() => -Infinity); // throws an error
|
|
939
|
+
* ```
|
|
940
|
+
*
|
|
941
|
+
* @returns The callback output once it passes.
|
|
942
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
943
|
+
* @see
|
|
944
|
+
* - {@link waitUntil.isNaN} : an opposite assertion.
|
|
945
|
+
* - {@link waitUntil.isInfinite} : an opposite assertion.
|
|
946
|
+
*/
|
|
947
|
+
isFinite: typeof autoGuardSymbol;
|
|
948
|
+
/**
|
|
949
|
+
* Repeatedly calls a callback until its output is a number that is either `Infinity` or
|
|
950
|
+
* `-Infinity`. Once the callback output passes, it is returned. If the attempts time out,
|
|
951
|
+
* an error is thrown.
|
|
952
|
+
*
|
|
953
|
+
* Performs no type guarding.
|
|
954
|
+
*
|
|
955
|
+
* @example
|
|
956
|
+
*
|
|
957
|
+
* ```ts
|
|
958
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
959
|
+
*
|
|
960
|
+
* await waitUntil.isInfinite(() => 10); // throws an error
|
|
961
|
+
* await waitUntil.isInfinite(() => parseInt('invalid')); // throws an error
|
|
962
|
+
* await waitUntil.isInfinite(() => Infinity); // returns `Infinity`
|
|
963
|
+
* await waitUntil.isInfinite(() => -Infinity); // returns `-Infinity`
|
|
964
|
+
* ```
|
|
965
|
+
*
|
|
966
|
+
* @returns The callback output once it passes.
|
|
967
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
968
|
+
* @see
|
|
969
|
+
* - {@link waitUntil.isNaN} : an opposite assertion.
|
|
970
|
+
* - {@link waitUntil.isInfinite} : an opposite assertion.
|
|
971
|
+
*/
|
|
972
|
+
isInfinite: typeof autoGuardSymbol;
|
|
973
|
+
/**
|
|
974
|
+
* Repeatedly calls a callback until its output is a number that is within ±`delta` of the
|
|
975
|
+
* expectation. Once the callback output passes, it is returned. If the attempts time out,
|
|
976
|
+
* an error is thrown.
|
|
977
|
+
*
|
|
978
|
+
* Performs no type guarding.
|
|
979
|
+
*
|
|
980
|
+
* @example
|
|
981
|
+
*
|
|
982
|
+
* ```ts
|
|
983
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
984
|
+
*
|
|
985
|
+
* await waitUntil.isApproximately(8, 4, () => 10); // returns `10`
|
|
986
|
+
* await waitUntil.isApproximately(12, 4, () => 10); // returns `10`
|
|
987
|
+
* await waitUntil.isApproximately(8, 1, () => 10); // throws an error
|
|
988
|
+
* await waitUntil.isApproximately(12, 1, () => 10); // throws an error
|
|
989
|
+
* ```
|
|
990
|
+
*
|
|
991
|
+
* @returns The callback output once it passes.
|
|
992
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
993
|
+
* @see
|
|
994
|
+
* - {@link waitUntil.isNotApproximately} : the opposite assertion.
|
|
995
|
+
*/
|
|
996
|
+
isApproximately: typeof autoGuardSymbol;
|
|
997
|
+
/**
|
|
998
|
+
* Repeatedly calls a callback until its output is a number that is outside ±`delta` of the
|
|
999
|
+
* expectation. Once the callback output passes, it is returned. If the attempts time out,
|
|
1000
|
+
* an error is thrown.
|
|
1001
|
+
*
|
|
1002
|
+
* Performs no type guarding.
|
|
1003
|
+
*
|
|
1004
|
+
* @example
|
|
1005
|
+
*
|
|
1006
|
+
* ```ts
|
|
1007
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1008
|
+
*
|
|
1009
|
+
* await waitUntil.isNotApproximately(8, 4, () => 10); // throws an error
|
|
1010
|
+
* await waitUntil.isNotApproximately(12, 4, () => 10); // throws an error
|
|
1011
|
+
* await waitUntil.isNotApproximately(8, 1, () => 10); // returns `10`
|
|
1012
|
+
* await waitUntil.isNotApproximately(12, 1, () => 10); // returns `10`
|
|
1013
|
+
* ```
|
|
1014
|
+
*
|
|
1015
|
+
* @returns The callback output once it passes.
|
|
1016
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
1017
|
+
* @see
|
|
1018
|
+
* - {@link waitUntil.isApproximately} : the opposite assertion.
|
|
1019
|
+
*/
|
|
1020
|
+
isNotApproximately: typeof autoGuardSymbol;
|
|
1021
|
+
};
|
|
68
1022
|
};
|
|
69
1023
|
export {};
|