@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,4 +1,5 @@
|
|
|
1
1
|
import { AnyFunction, MaybePromise, NarrowToActual, NarrowToExpected, UnknownObject } from '@augment-vir/core';
|
|
2
|
+
import { autoGuardSymbol } from '../guard-types/guard-override.js';
|
|
2
3
|
import { WaitUntilOptions } from '../guard-types/wait-until-function.js';
|
|
3
4
|
declare function isNotArray<const Actual>(actual: Actual, failureMessage?: string | undefined): asserts actual is Exclude<Actual, ReadonlyArray<unknown>>;
|
|
4
5
|
declare function isNotBigInt<const Actual>(actual: Actual, failureMessage?: string | undefined): asserts actual is Exclude<Actual, bigint>;
|
|
@@ -21,199 +22,1977 @@ declare function isSymbol(actual: unknown, failureMessage?: string | undefined):
|
|
|
21
22
|
declare function isUndefined(actual: unknown, failureMessage?: string | undefined): asserts actual is undefined;
|
|
22
23
|
declare function isNull(actual: unknown, failureMessage?: string | undefined): asserts actual is null;
|
|
23
24
|
export declare const runtimeTypeGuards: {
|
|
24
|
-
|
|
25
|
+
assert: {
|
|
25
26
|
/**
|
|
26
|
-
*
|
|
27
|
+
* Asserts that a value is an array.
|
|
27
28
|
*
|
|
28
29
|
* Type guards the value.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* import {assert} from '@augment-vir/assert';
|
|
35
|
+
*
|
|
36
|
+
* assert.isArray([]); // passes
|
|
37
|
+
* assert.isArray({length: 4}); // fails
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
41
|
+
* @see
|
|
42
|
+
* - {@link assert.isNotArray} : the opposite assertion.
|
|
29
43
|
*/
|
|
30
44
|
isArray: typeof isArray;
|
|
31
45
|
/**
|
|
32
|
-
*
|
|
46
|
+
* Asserts that a value is a BigInt.
|
|
33
47
|
*
|
|
34
48
|
* Type guards the value.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
*
|
|
52
|
+
* ```ts
|
|
53
|
+
* import {assert} from '@augment-vir/assert';
|
|
54
|
+
*
|
|
55
|
+
* assert.isBigInt(123n); // passes
|
|
56
|
+
* assert.isBigInt(123); // fails
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
60
|
+
* @see
|
|
61
|
+
* - {@link assert.isNotBigInt} : the opposite assertion.
|
|
35
62
|
*/
|
|
36
63
|
isBigInt: typeof isBigInt;
|
|
37
64
|
/**
|
|
38
|
-
*
|
|
65
|
+
* Asserts that a value is a boolean.
|
|
39
66
|
*
|
|
40
67
|
* Type guards the value.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
*
|
|
71
|
+
* ```ts
|
|
72
|
+
* import {assert} from '@augment-vir/assert';
|
|
73
|
+
*
|
|
74
|
+
* assert.isBoolean(true); // passes
|
|
75
|
+
* assert.isBoolean('true'); // fails
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
79
|
+
* @see
|
|
80
|
+
* - {@link assert.isNotBoolean} : the opposite assertion.
|
|
41
81
|
*/
|
|
42
82
|
isBoolean: typeof isBoolean;
|
|
43
83
|
/**
|
|
44
|
-
*
|
|
84
|
+
* Asserts that a value is a function.
|
|
45
85
|
*
|
|
46
86
|
* Type guards the value.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
*
|
|
90
|
+
* ```ts
|
|
91
|
+
* import {assert} from '@augment-vir/assert';
|
|
92
|
+
*
|
|
93
|
+
* assert.isFunction(() => {}); // passes
|
|
94
|
+
* assert.isFunction({}); // fails
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
98
|
+
* @see
|
|
99
|
+
* - {@link assert.isNotFunction} : the opposite assertion.
|
|
47
100
|
*/
|
|
48
101
|
isFunction: typeof isFunction;
|
|
49
102
|
/**
|
|
50
|
-
*
|
|
103
|
+
* Asserts that a value is exactly `null`.
|
|
51
104
|
*
|
|
52
105
|
* Type guards the value.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
*
|
|
109
|
+
* ```ts
|
|
110
|
+
* import {assert} from '@augment-vir/assert';
|
|
111
|
+
*
|
|
112
|
+
* assert.isNull(null); // passes
|
|
113
|
+
* assert.isNull(undefined); // fails
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
117
|
+
* @see
|
|
118
|
+
* - {@link assert.isNotFunction} : the opposite assertion.
|
|
53
119
|
*/
|
|
54
120
|
isNull: typeof isNull;
|
|
55
121
|
/**
|
|
56
|
-
*
|
|
122
|
+
* Asserts that a value is a number. This excludes `NaN`.
|
|
57
123
|
*
|
|
58
124
|
* Type guards the value.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
*
|
|
128
|
+
* ```ts
|
|
129
|
+
* import {assert} from '@augment-vir/assert';
|
|
130
|
+
*
|
|
131
|
+
* assert.isNumber(123); // passes
|
|
132
|
+
* assert.isNumber(123n); // fails
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
136
|
+
* @see
|
|
137
|
+
* - {@link assert.isNotFunction} : the opposite assertion.
|
|
59
138
|
*/
|
|
60
139
|
isNumber: typeof isNumber;
|
|
61
140
|
/**
|
|
62
|
-
*
|
|
141
|
+
* Asserts that a value is an object. This excludes arrays.
|
|
63
142
|
*
|
|
64
143
|
* Type guards the value.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
*
|
|
147
|
+
* ```ts
|
|
148
|
+
* import {assert} from '@augment-vir/assert';
|
|
149
|
+
*
|
|
150
|
+
* assert.isObject({}); // passes
|
|
151
|
+
* assert.isObject([]); // fails
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
155
|
+
* @see
|
|
156
|
+
* - {@link assert.isNotFunction} : the opposite assertion.
|
|
65
157
|
*/
|
|
66
158
|
isObject: typeof isObject;
|
|
67
159
|
/**
|
|
68
|
-
*
|
|
160
|
+
* Asserts that a value is a string.
|
|
69
161
|
*
|
|
70
162
|
* Type guards the value.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
*
|
|
166
|
+
* ```ts
|
|
167
|
+
* import {assert} from '@augment-vir/assert';
|
|
168
|
+
*
|
|
169
|
+
* assert.isString(''); // passes
|
|
170
|
+
* assert.isString(5); // fails
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
174
|
+
* @see
|
|
175
|
+
* - {@link assert.isNotFunction} : the opposite assertion.
|
|
71
176
|
*/
|
|
72
177
|
isString: typeof isString;
|
|
73
178
|
/**
|
|
74
|
-
*
|
|
179
|
+
* Asserts that a value is a symbol.
|
|
75
180
|
*
|
|
76
181
|
* Type guards the value.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
*
|
|
185
|
+
* ```ts
|
|
186
|
+
* import {assert} from '@augment-vir/assert';
|
|
187
|
+
*
|
|
188
|
+
* assert.isSymbol(Symbol('my-symbol')); // passes
|
|
189
|
+
* assert.isSymbol('my-symbol'); // fails
|
|
190
|
+
* ```
|
|
191
|
+
*
|
|
192
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
193
|
+
* @see
|
|
194
|
+
* - {@link assert.isNotFunction} : the opposite assertion.
|
|
77
195
|
*/
|
|
78
196
|
isSymbol: typeof isSymbol;
|
|
79
197
|
/**
|
|
80
|
-
*
|
|
198
|
+
* Asserts that a value is exactly `undefined`.
|
|
81
199
|
*
|
|
82
200
|
* Type guards the value.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
*
|
|
204
|
+
* ```ts
|
|
205
|
+
* import {assert} from '@augment-vir/assert';
|
|
206
|
+
*
|
|
207
|
+
* assert.isUndefined(undefined); // passes
|
|
208
|
+
* assert.isUndefined(null); // fails
|
|
209
|
+
* ```
|
|
210
|
+
*
|
|
211
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
212
|
+
* @see
|
|
213
|
+
* - {@link assert.isNotFunction} : the opposite assertion.
|
|
83
214
|
*/
|
|
84
215
|
isUndefined: typeof isUndefined;
|
|
85
216
|
/**
|
|
86
|
-
*
|
|
217
|
+
* Asserts that a value is _not_ an array.
|
|
87
218
|
*
|
|
88
219
|
* Type guards the value.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
*
|
|
223
|
+
* ```ts
|
|
224
|
+
* import {assert} from '@augment-vir/assert';
|
|
225
|
+
*
|
|
226
|
+
* assert.isNotArray([]); // fails
|
|
227
|
+
* assert.isNotArray({length: 4}); // passes
|
|
228
|
+
* ```
|
|
229
|
+
*
|
|
230
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
231
|
+
* @see
|
|
232
|
+
* - {@link assert.isArray} : the opposite assertion.
|
|
89
233
|
*/
|
|
90
234
|
isNotArray: typeof isNotArray;
|
|
91
235
|
/**
|
|
92
|
-
*
|
|
236
|
+
* Asserts that a value is _not_ a BigInt.
|
|
93
237
|
*
|
|
94
238
|
* Type guards the value.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
*
|
|
242
|
+
* ```ts
|
|
243
|
+
* import {assert} from '@augment-vir/assert';
|
|
244
|
+
*
|
|
245
|
+
* assert.isNotBigInt(123n); // fails
|
|
246
|
+
* assert.isNotBigInt(123); // passes
|
|
247
|
+
* ```
|
|
248
|
+
*
|
|
249
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
250
|
+
* @see
|
|
251
|
+
* - {@link assert.isBigInt} : the opposite assertion.
|
|
95
252
|
*/
|
|
96
253
|
isNotBigInt: typeof isNotBigInt;
|
|
97
254
|
/**
|
|
98
|
-
*
|
|
255
|
+
* Asserts that a value is _not_ a boolean.
|
|
99
256
|
*
|
|
100
257
|
* Type guards the value.
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
*
|
|
261
|
+
* ```ts
|
|
262
|
+
* import {assert} from '@augment-vir/assert';
|
|
263
|
+
*
|
|
264
|
+
* assert.isNotBoolean(true); // fails
|
|
265
|
+
* assert.isNotBoolean('true'); // passes
|
|
266
|
+
* ```
|
|
267
|
+
*
|
|
268
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
269
|
+
* @see
|
|
270
|
+
* - {@link assert.isBoolean} : the opposite assertion.
|
|
101
271
|
*/
|
|
102
272
|
isNotBoolean: typeof isNotBoolean;
|
|
103
273
|
/**
|
|
104
|
-
*
|
|
274
|
+
* Asserts that a value is _not_ a function.
|
|
105
275
|
*
|
|
106
276
|
* Type guards the value.
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
*
|
|
280
|
+
* ```ts
|
|
281
|
+
* import {assert} from '@augment-vir/assert';
|
|
282
|
+
*
|
|
283
|
+
* assert.isNotFunction(() => {}); // fails
|
|
284
|
+
* assert.isNotFunction({}); // passes
|
|
285
|
+
* ```
|
|
286
|
+
*
|
|
287
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
288
|
+
* @see
|
|
289
|
+
* - {@link assert.isFunction} : the opposite assertion.
|
|
107
290
|
*/
|
|
108
291
|
isNotFunction: typeof isNotFunction;
|
|
109
292
|
/**
|
|
110
|
-
*
|
|
293
|
+
* Asserts that a value is _not_ exactly `null`.
|
|
294
|
+
*
|
|
295
|
+
* Type guards the value.
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
*
|
|
299
|
+
* ```ts
|
|
300
|
+
* import {assert} from '@augment-vir/assert';
|
|
301
|
+
*
|
|
302
|
+
* assert.isNotNull(null); // fails
|
|
303
|
+
* assert.isNotNull(undefined); // passes
|
|
304
|
+
* ```
|
|
305
|
+
*
|
|
306
|
+
* @throws {@link AssertionError} If the assertion failed. @see
|
|
307
|
+
* @see
|
|
308
|
+
* - {@link assert.isFunction} : the opposite assertion.
|
|
309
|
+
*/
|
|
310
|
+
isNotNull: typeof isNotNull;
|
|
311
|
+
/**
|
|
312
|
+
* Asserts that a value is _not_ a number. This includes `NaN`.
|
|
111
313
|
*
|
|
112
314
|
* Type guards the value.
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
*
|
|
318
|
+
* ```ts
|
|
319
|
+
* import {assert} from '@augment-vir/assert';
|
|
320
|
+
*
|
|
321
|
+
* assert.isNotNumber(123); // fails
|
|
322
|
+
* assert.isNotNumber(123n); // passes
|
|
323
|
+
* ```
|
|
324
|
+
*
|
|
325
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
326
|
+
* @see
|
|
327
|
+
* - {@link assert.isNotFunction} : the opposite assertion.
|
|
113
328
|
*/
|
|
114
329
|
isNotNumber: typeof isNotNumber;
|
|
115
330
|
/**
|
|
116
|
-
*
|
|
331
|
+
* Asserts that a value is _not_ an object. This includes arrays.
|
|
117
332
|
*
|
|
118
333
|
* Type guards the value.
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
*
|
|
337
|
+
* ```ts
|
|
338
|
+
* import {assert} from '@augment-vir/assert';
|
|
339
|
+
*
|
|
340
|
+
* assert.isNotObject({}); // fails
|
|
341
|
+
* assert.isNotObject([]); // passes
|
|
342
|
+
* ```
|
|
343
|
+
*
|
|
344
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
345
|
+
* @see
|
|
346
|
+
* - {@link assert.isFunction} : the opposite assertion.
|
|
119
347
|
*/
|
|
120
348
|
isNotObject: typeof isNotObject;
|
|
121
349
|
/**
|
|
122
|
-
*
|
|
350
|
+
* Asserts that a value is _not_ a string.
|
|
123
351
|
*
|
|
124
352
|
* Type guards the value.
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
*
|
|
356
|
+
* ```ts
|
|
357
|
+
* import {assert} from '@augment-vir/assert';
|
|
358
|
+
*
|
|
359
|
+
* assert.isNotString(''); // fails
|
|
360
|
+
* assert.isNotString(5); // passes
|
|
361
|
+
* ```
|
|
362
|
+
*
|
|
363
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
364
|
+
* @see
|
|
365
|
+
* - {@link assert.isFunction} : the opposite assertion.
|
|
125
366
|
*/
|
|
126
367
|
isNotString: typeof isNotString;
|
|
127
368
|
/**
|
|
128
|
-
*
|
|
369
|
+
* Asserts that a value is _not_ a symbol.
|
|
129
370
|
*
|
|
130
371
|
* Type guards the value.
|
|
372
|
+
*
|
|
373
|
+
* @example
|
|
374
|
+
*
|
|
375
|
+
* ```ts
|
|
376
|
+
* import {assert} from '@augment-vir/assert';
|
|
377
|
+
*
|
|
378
|
+
* assert.isNotSymbol(Symbol('my-symbol')); // fails
|
|
379
|
+
* assert.isNotSymbol('my-symbol'); // passes
|
|
380
|
+
* ```
|
|
381
|
+
*
|
|
382
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
383
|
+
* @see
|
|
384
|
+
* - {@link assert.isFunction} : the opposite assertion.
|
|
131
385
|
*/
|
|
132
386
|
isNotSymbol: typeof isNotSymbol;
|
|
133
387
|
/**
|
|
134
|
-
*
|
|
388
|
+
* Asserts that a value is _not_ exactly `undefined`.
|
|
135
389
|
*
|
|
136
390
|
* Type guards the value.
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
*
|
|
394
|
+
* ```ts
|
|
395
|
+
* import {assert} from '@augment-vir/assert';
|
|
396
|
+
*
|
|
397
|
+
* assert.isNotUndefined(undefined); // fails
|
|
398
|
+
* assert.isNotUndefined(null); // passes
|
|
399
|
+
* ```
|
|
400
|
+
*
|
|
401
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
402
|
+
* @see
|
|
403
|
+
* - {@link assert.isFunction} : the opposite assertion.
|
|
137
404
|
*/
|
|
138
405
|
isNotUndefined: typeof isNotUndefined;
|
|
406
|
+
};
|
|
407
|
+
check: {
|
|
139
408
|
/**
|
|
140
|
-
*
|
|
409
|
+
* Checks that a value is an array.
|
|
141
410
|
*
|
|
142
411
|
* Type guards the value.
|
|
412
|
+
*
|
|
413
|
+
* @example
|
|
414
|
+
*
|
|
415
|
+
* ```ts
|
|
416
|
+
* import {check} from '@augment-vir/assert';
|
|
417
|
+
*
|
|
418
|
+
* check.isArray([]); // returns `true`
|
|
419
|
+
* check.isArray({length: 4}); // returns `false`
|
|
420
|
+
* ```
|
|
421
|
+
*
|
|
422
|
+
* @see
|
|
423
|
+
* - {@link check.isNotArray} : the opposite check.
|
|
424
|
+
*/
|
|
425
|
+
isArray: typeof autoGuardSymbol;
|
|
426
|
+
/**
|
|
427
|
+
* Checks that a value is a BigInt.
|
|
428
|
+
*
|
|
429
|
+
* Type guards the value.
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
*
|
|
433
|
+
* ```ts
|
|
434
|
+
* import {check} from '@augment-vir/assert';
|
|
435
|
+
*
|
|
436
|
+
* check.isBigInt(123n); // returns `true`
|
|
437
|
+
* check.isBigInt(123); // returns `false`
|
|
438
|
+
* ```
|
|
439
|
+
*
|
|
440
|
+
* @see
|
|
441
|
+
* - {@link check.isNotBigInt} : the opposite check.
|
|
442
|
+
*/
|
|
443
|
+
isBigInt: typeof autoGuardSymbol;
|
|
444
|
+
/**
|
|
445
|
+
* Checks that a value is a boolean.
|
|
446
|
+
*
|
|
447
|
+
* Type guards the value.
|
|
448
|
+
*
|
|
449
|
+
* @example
|
|
450
|
+
*
|
|
451
|
+
* ```ts
|
|
452
|
+
* import {check} from '@augment-vir/assert';
|
|
453
|
+
*
|
|
454
|
+
* check.isBoolean(true); // returns `true`
|
|
455
|
+
* check.isBoolean('true'); // returns `false`
|
|
456
|
+
* ```
|
|
457
|
+
*
|
|
458
|
+
* @see
|
|
459
|
+
* - {@link check.isNotBoolean} : the opposite check.
|
|
460
|
+
*/
|
|
461
|
+
isBoolean: typeof autoGuardSymbol;
|
|
462
|
+
/**
|
|
463
|
+
* Checks that a value is a function.
|
|
464
|
+
*
|
|
465
|
+
* Type guards the value.
|
|
466
|
+
*
|
|
467
|
+
* @example
|
|
468
|
+
*
|
|
469
|
+
* ```ts
|
|
470
|
+
* import {check} from '@augment-vir/assert';
|
|
471
|
+
*
|
|
472
|
+
* check.isFunction(() => {}); // returns `true`
|
|
473
|
+
* check.isFunction({}); // returns `false`
|
|
474
|
+
* ```
|
|
475
|
+
*
|
|
476
|
+
* @see
|
|
477
|
+
* - {@link check.isNotFunction} : the opposite check.
|
|
143
478
|
*/
|
|
144
|
-
isNotNull: typeof isNotNull;
|
|
145
|
-
};
|
|
146
|
-
checkOverrides: {
|
|
147
479
|
isFunction: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is NarrowToActual<Actual, AnyFunction>;
|
|
480
|
+
/**
|
|
481
|
+
* Checks that a value is exactly `null`.
|
|
482
|
+
*
|
|
483
|
+
* Type guards the value.
|
|
484
|
+
*
|
|
485
|
+
* @example
|
|
486
|
+
*
|
|
487
|
+
* ```ts
|
|
488
|
+
* import {check} from '@augment-vir/assert';
|
|
489
|
+
*
|
|
490
|
+
* check.isNull(null); // returns `true`
|
|
491
|
+
* check.isNull(undefined); // returns `false`
|
|
492
|
+
* ```
|
|
493
|
+
*
|
|
494
|
+
* @see
|
|
495
|
+
* - {@link check.isNotFunction} : the opposite check.
|
|
496
|
+
*/
|
|
497
|
+
isNull: typeof autoGuardSymbol;
|
|
498
|
+
/**
|
|
499
|
+
* Checks that a value is a number. This excludes `NaN`.
|
|
500
|
+
*
|
|
501
|
+
* Type guards the value.
|
|
502
|
+
*
|
|
503
|
+
* @example
|
|
504
|
+
*
|
|
505
|
+
* ```ts
|
|
506
|
+
* import {check} from '@augment-vir/assert';
|
|
507
|
+
*
|
|
508
|
+
* check.isNumber(123); // returns `true`
|
|
509
|
+
* check.isNumber(123n); // returns `false`
|
|
510
|
+
* ```
|
|
511
|
+
*
|
|
512
|
+
* @see
|
|
513
|
+
* - {@link check.isNotFunction} : the opposite check.
|
|
514
|
+
*/
|
|
515
|
+
isNumber: typeof autoGuardSymbol;
|
|
516
|
+
/**
|
|
517
|
+
* Checks that a value is an object. This excludes arrays.
|
|
518
|
+
*
|
|
519
|
+
* Type guards the value.
|
|
520
|
+
*
|
|
521
|
+
* @example
|
|
522
|
+
*
|
|
523
|
+
* ```ts
|
|
524
|
+
* import {check} from '@augment-vir/assert';
|
|
525
|
+
*
|
|
526
|
+
* check.isObject({}); // returns `true`
|
|
527
|
+
* check.isObject([]); // returns `false`
|
|
528
|
+
* ```
|
|
529
|
+
*
|
|
530
|
+
* @see
|
|
531
|
+
* - {@link check.isNotFunction} : the opposite check.
|
|
532
|
+
*/
|
|
533
|
+
isObject: typeof autoGuardSymbol;
|
|
534
|
+
/**
|
|
535
|
+
* Checks that a value is a string.
|
|
536
|
+
*
|
|
537
|
+
* Type guards the value.
|
|
538
|
+
*
|
|
539
|
+
* @example
|
|
540
|
+
*
|
|
541
|
+
* ```ts
|
|
542
|
+
* import {check} from '@augment-vir/assert';
|
|
543
|
+
*
|
|
544
|
+
* check.isString(''); // returns `true`
|
|
545
|
+
* check.isString(5); // returns `false`
|
|
546
|
+
* ```
|
|
547
|
+
*
|
|
548
|
+
* @see
|
|
549
|
+
* - {@link check.isNotFunction} : the opposite check.
|
|
550
|
+
*/
|
|
551
|
+
isString: typeof autoGuardSymbol;
|
|
552
|
+
/**
|
|
553
|
+
* Checks that a value is a symbol.
|
|
554
|
+
*
|
|
555
|
+
* Type guards the value.
|
|
556
|
+
*
|
|
557
|
+
* @example
|
|
558
|
+
*
|
|
559
|
+
* ```ts
|
|
560
|
+
* import {check} from '@augment-vir/assert';
|
|
561
|
+
*
|
|
562
|
+
* check.isSymbol(Symbol('my-symbol')); // returns `true`
|
|
563
|
+
* check.isSymbol('my-symbol'); // returns `false`
|
|
564
|
+
* ```
|
|
565
|
+
*
|
|
566
|
+
* @see
|
|
567
|
+
* - {@link check.isNotFunction} : the opposite check.
|
|
568
|
+
*/
|
|
569
|
+
isSymbol: typeof autoGuardSymbol;
|
|
570
|
+
/**
|
|
571
|
+
* Checks that a value is exactly `undefined`.
|
|
572
|
+
*
|
|
573
|
+
* Type guards the value.
|
|
574
|
+
*
|
|
575
|
+
* @example
|
|
576
|
+
*
|
|
577
|
+
* ```ts
|
|
578
|
+
* import {check} from '@augment-vir/assert';
|
|
579
|
+
*
|
|
580
|
+
* check.isUndefined(undefined); // returns `true`
|
|
581
|
+
* check.isUndefined(null); // returns `false`
|
|
582
|
+
* ```
|
|
583
|
+
*
|
|
584
|
+
* @see
|
|
585
|
+
* - {@link check.isNotFunction} : the opposite check.
|
|
586
|
+
*/
|
|
587
|
+
isUndefined: typeof autoGuardSymbol;
|
|
588
|
+
/**
|
|
589
|
+
* Checks that a value is _not_ an array.
|
|
590
|
+
*
|
|
591
|
+
* Type guards the value.
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
*
|
|
595
|
+
* ```ts
|
|
596
|
+
* import {check} from '@augment-vir/assert';
|
|
597
|
+
*
|
|
598
|
+
* check.isNotArray([]); // returns `false`
|
|
599
|
+
* check.isNotArray({length: 4}); // returns `true`
|
|
600
|
+
* ```
|
|
601
|
+
*
|
|
602
|
+
* @see
|
|
603
|
+
* - {@link check.isArray} : the opposite check.
|
|
604
|
+
*/
|
|
148
605
|
isNotArray: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, ReadonlyArray<unknown>>;
|
|
606
|
+
/**
|
|
607
|
+
* Checks that a value is _not_ a BigInt.
|
|
608
|
+
*
|
|
609
|
+
* Type guards the value.
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
*
|
|
613
|
+
* ```ts
|
|
614
|
+
* import {check} from '@augment-vir/assert';
|
|
615
|
+
*
|
|
616
|
+
* check.isNotBigInt(123n); // returns `false`
|
|
617
|
+
* check.isNotBigInt(123); // returns `true`
|
|
618
|
+
* ```
|
|
619
|
+
*
|
|
620
|
+
* @see
|
|
621
|
+
* - {@link check.isBigInt} : the opposite check.
|
|
622
|
+
*/
|
|
149
623
|
isNotBigInt: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, bigint>;
|
|
624
|
+
/**
|
|
625
|
+
* Checks that a value is _not_ a boolean.
|
|
626
|
+
*
|
|
627
|
+
* Type guards the value.
|
|
628
|
+
*
|
|
629
|
+
* @example
|
|
630
|
+
*
|
|
631
|
+
* ```ts
|
|
632
|
+
* import {check} from '@augment-vir/assert';
|
|
633
|
+
*
|
|
634
|
+
* check.isNotBoolean(true); // returns `false`
|
|
635
|
+
* check.isNotBoolean('true'); // returns `true`
|
|
636
|
+
* ```
|
|
637
|
+
*
|
|
638
|
+
* @see
|
|
639
|
+
* - {@link check.isBoolean} : the opposite check.
|
|
640
|
+
*/
|
|
150
641
|
isNotBoolean: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, boolean>;
|
|
642
|
+
/**
|
|
643
|
+
* Checks that a value is _not_ a function.
|
|
644
|
+
*
|
|
645
|
+
* Type guards the value.
|
|
646
|
+
*
|
|
647
|
+
* @example
|
|
648
|
+
*
|
|
649
|
+
* ```ts
|
|
650
|
+
* import {check} from '@augment-vir/assert';
|
|
651
|
+
*
|
|
652
|
+
* check.isNotFunction(() => {}); // returns `false`
|
|
653
|
+
* check.isNotFunction({}); // returns `true`
|
|
654
|
+
* ```
|
|
655
|
+
*
|
|
656
|
+
* @see
|
|
657
|
+
* - {@link check.isFunction} : the opposite check.
|
|
658
|
+
*/
|
|
151
659
|
isNotFunction: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, AnyFunction>;
|
|
660
|
+
/**
|
|
661
|
+
* Checks that a value is _not_ exactly `null`.
|
|
662
|
+
*
|
|
663
|
+
* Type guards the value.
|
|
664
|
+
*
|
|
665
|
+
* @example
|
|
666
|
+
*
|
|
667
|
+
* ```ts
|
|
668
|
+
* import {check} from '@augment-vir/assert';
|
|
669
|
+
*
|
|
670
|
+
* check.isNotNull(null); // returns `false`
|
|
671
|
+
* check.isNotNull(undefined); // returns `true`
|
|
672
|
+
* ```
|
|
673
|
+
*
|
|
674
|
+
* @see
|
|
675
|
+
* - {@link check.isFunction} : the opposite check.
|
|
676
|
+
*/
|
|
152
677
|
isNotNull: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, null>;
|
|
678
|
+
/**
|
|
679
|
+
* Checks that a value is _not_ a number. This includes `NaN`.
|
|
680
|
+
*
|
|
681
|
+
* Type guards the value.
|
|
682
|
+
*
|
|
683
|
+
* @example
|
|
684
|
+
*
|
|
685
|
+
* ```ts
|
|
686
|
+
* import {check} from '@augment-vir/assert';
|
|
687
|
+
*
|
|
688
|
+
* check.isNotNumber(123); // returns `false`
|
|
689
|
+
* check.isNotNumber(123n); // returns `true`
|
|
690
|
+
* ```
|
|
691
|
+
*
|
|
692
|
+
* @see
|
|
693
|
+
* - {@link check.isNotFunction} : the opposite check.
|
|
694
|
+
*/
|
|
153
695
|
isNotNumber: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, number>;
|
|
696
|
+
/**
|
|
697
|
+
* Checks that a value is _not_ an object. This includes arrays.
|
|
698
|
+
*
|
|
699
|
+
* Type guards the value.
|
|
700
|
+
*
|
|
701
|
+
* @example
|
|
702
|
+
*
|
|
703
|
+
* ```ts
|
|
704
|
+
* import {check} from '@augment-vir/assert';
|
|
705
|
+
*
|
|
706
|
+
* check.isNotObject({}); // returns `false`
|
|
707
|
+
* check.isNotObject([]); // returns `true`
|
|
708
|
+
* ```
|
|
709
|
+
*
|
|
710
|
+
* @see
|
|
711
|
+
* - {@link check.isFunction} : the opposite check.
|
|
712
|
+
*/
|
|
154
713
|
isNotObject: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, UnknownObject>;
|
|
714
|
+
/**
|
|
715
|
+
* Checks that a value is _not_ a string.
|
|
716
|
+
*
|
|
717
|
+
* Type guards the value.
|
|
718
|
+
*
|
|
719
|
+
* @example
|
|
720
|
+
*
|
|
721
|
+
* ```ts
|
|
722
|
+
* import {check} from '@augment-vir/assert';
|
|
723
|
+
*
|
|
724
|
+
* check.isNotString(''); // returns `false`
|
|
725
|
+
* check.isNotString(5); // returns `true`
|
|
726
|
+
* ```
|
|
727
|
+
*
|
|
728
|
+
* @see
|
|
729
|
+
* - {@link check.isFunction} : the opposite check.
|
|
730
|
+
*/
|
|
155
731
|
isNotString: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, string>;
|
|
156
|
-
|
|
732
|
+
/**
|
|
733
|
+
* Checks that a value is _not_ a symbol.
|
|
734
|
+
*
|
|
735
|
+
* Type guards the value.
|
|
736
|
+
*
|
|
737
|
+
* @example
|
|
738
|
+
*
|
|
739
|
+
* ```ts
|
|
740
|
+
* import {check} from '@augment-vir/assert';
|
|
741
|
+
*
|
|
742
|
+
* check.isNotSymbol(Symbol('my-symbol')); // returns `false`
|
|
743
|
+
* check.isNotSymbol('my-symbol'); // returns `true`
|
|
744
|
+
* ```
|
|
745
|
+
*
|
|
746
|
+
* @see
|
|
747
|
+
* - {@link check.isFunction} : the opposite check.
|
|
748
|
+
*/
|
|
157
749
|
isNotSymbol: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, symbol>;
|
|
750
|
+
/**
|
|
751
|
+
* Checks that a value is _not_ exactly `undefined`.
|
|
752
|
+
*
|
|
753
|
+
* Type guards the value.
|
|
754
|
+
*
|
|
755
|
+
* @example
|
|
756
|
+
*
|
|
757
|
+
* ```ts
|
|
758
|
+
* import {check} from '@augment-vir/assert';
|
|
759
|
+
*
|
|
760
|
+
* check.isNotUndefined(undefined); // returns `false`
|
|
761
|
+
* check.isNotUndefined(null); // returns `true`
|
|
762
|
+
* ```
|
|
763
|
+
*
|
|
764
|
+
* @see
|
|
765
|
+
* - {@link check.isFunction} : the opposite check.
|
|
766
|
+
*/
|
|
767
|
+
isNotUndefined: <const Actual>(actual: Actual, failureMessage?: string | undefined) => actual is Exclude<Actual, undefined>;
|
|
158
768
|
};
|
|
159
|
-
|
|
160
|
-
isFunction: <const Actual>(actual: Actual, failureMessage?: string | undefined) => NarrowToActual<Actual, AnyFunction>;
|
|
769
|
+
assertWrap: {
|
|
161
770
|
/**
|
|
162
|
-
*
|
|
163
|
-
* symbol. this seems to be a bug with TypeScript itself.
|
|
771
|
+
* Asserts that a value is an array. Returns the value if the assertion passes.
|
|
164
772
|
*
|
|
165
|
-
*
|
|
773
|
+
* Type guards the value.
|
|
166
774
|
*
|
|
167
|
-
* @example
|
|
168
|
-
*
|
|
775
|
+
* @example
|
|
776
|
+
*
|
|
777
|
+
* ```ts
|
|
778
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
779
|
+
*
|
|
780
|
+
* assertWrap.isArray([]); // returns `[]`
|
|
781
|
+
* assertWrap.isArray({length: 4}); // throws an error
|
|
782
|
+
* ```
|
|
783
|
+
*
|
|
784
|
+
* @returns The value if the assertion passes.
|
|
785
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
786
|
+
* @see
|
|
787
|
+
* - {@link assertWrap.isNotArray} : the opposite assertion.
|
|
788
|
+
*/
|
|
789
|
+
isArray: typeof autoGuardSymbol;
|
|
790
|
+
/**
|
|
791
|
+
* Asserts that a value is a BigInt. Returns the value if the assertion passes.
|
|
792
|
+
*
|
|
793
|
+
* Type guards the value.
|
|
794
|
+
*
|
|
795
|
+
* @example
|
|
796
|
+
*
|
|
797
|
+
* ```ts
|
|
798
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
799
|
+
*
|
|
800
|
+
* assertWrap.isBigInt(123n); // returns `123n`
|
|
801
|
+
* assertWrap.isBigInt(123); // throws an error
|
|
802
|
+
* ```
|
|
803
|
+
*
|
|
804
|
+
* @returns The value if the assertion passes.
|
|
805
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
806
|
+
* @see
|
|
807
|
+
* - {@link assertWrap.isNotBigInt} : the opposite assertion.
|
|
808
|
+
*/
|
|
809
|
+
isBigInt: typeof autoGuardSymbol;
|
|
810
|
+
/**
|
|
811
|
+
* Asserts that a value is a boolean. Returns the value if the assertion passes.
|
|
812
|
+
*
|
|
813
|
+
* Type guards the value.
|
|
814
|
+
*
|
|
815
|
+
* @example
|
|
816
|
+
*
|
|
817
|
+
* ```ts
|
|
818
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
819
|
+
*
|
|
820
|
+
* assertWrap.isBoolean(true); // returns `true`
|
|
821
|
+
* assertWrap.isBoolean('true'); // throws an error
|
|
822
|
+
* ```
|
|
823
|
+
*
|
|
824
|
+
* @returns The value if the assertion passes.
|
|
825
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
826
|
+
* @see
|
|
827
|
+
* - {@link assertWrap.isNotBoolean} : the opposite assertion.
|
|
828
|
+
*/
|
|
829
|
+
isBoolean: typeof autoGuardSymbol;
|
|
830
|
+
/**
|
|
831
|
+
* Asserts that a value is a function. Returns the value if the assertion passes.
|
|
832
|
+
*
|
|
833
|
+
* Type guards the value.
|
|
834
|
+
*
|
|
835
|
+
* @example
|
|
836
|
+
*
|
|
837
|
+
* ```ts
|
|
838
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
839
|
+
*
|
|
840
|
+
* assertWrap.isFunction(() => {}); // returns `() => {}`
|
|
841
|
+
* assertWrap.isFunction({}); // throws an error
|
|
842
|
+
* ```
|
|
843
|
+
*
|
|
844
|
+
* @returns The value if the assertion passes.
|
|
845
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
846
|
+
* @see
|
|
847
|
+
* - {@link assertWrap.isNotFunction} : the opposite assertion.
|
|
848
|
+
*/
|
|
849
|
+
isFunction: <const Actual>(actual: Actual, failureMessage?: string | undefined) => NarrowToActual<Actual, AnyFunction>;
|
|
850
|
+
/**
|
|
851
|
+
* Asserts that a value is exactly `null. Returns the value if the assertion passes.
|
|
852
|
+
*
|
|
853
|
+
* Type guards the value.
|
|
854
|
+
*
|
|
855
|
+
* @example
|
|
856
|
+
*
|
|
857
|
+
* ```ts
|
|
858
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
859
|
+
*
|
|
860
|
+
* assertWrap.isNull(null); // returns `null`
|
|
861
|
+
* assertWrap.isNull(undefined); // throws an error
|
|
862
|
+
* ```
|
|
863
|
+
*
|
|
864
|
+
* @returns The value if the assertion passes.
|
|
865
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
866
|
+
* @see
|
|
867
|
+
* - {@link assertWrap.isNotFunction} : the opposite assertion.
|
|
868
|
+
*/
|
|
869
|
+
isNull: typeof autoGuardSymbol;
|
|
870
|
+
/**
|
|
871
|
+
* Asserts that a value is a number. This excludes `NaN. Returns the value if the assertion
|
|
872
|
+
* passes.
|
|
873
|
+
*
|
|
874
|
+
* Type guards the value.
|
|
875
|
+
*
|
|
876
|
+
* @example
|
|
877
|
+
*
|
|
878
|
+
* ```ts
|
|
879
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
880
|
+
*
|
|
881
|
+
* assertWrap.isNumber(123); // returns `123`
|
|
882
|
+
* assertWrap.isNumber(123n); // throws an error
|
|
883
|
+
* ```
|
|
884
|
+
*
|
|
885
|
+
* @returns The value if the assertion passes.
|
|
886
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
887
|
+
* @see
|
|
888
|
+
* - {@link assertWrap.isNotFunction} : the opposite assertion.
|
|
889
|
+
*/
|
|
890
|
+
isNumber: typeof autoGuardSymbol;
|
|
891
|
+
/**
|
|
892
|
+
* Asserts that a value is an object. This excludes arrays. Returns the value if the
|
|
893
|
+
* assertion passes.
|
|
894
|
+
*
|
|
895
|
+
* Type guards the value.
|
|
896
|
+
*
|
|
897
|
+
* @example
|
|
898
|
+
*
|
|
899
|
+
* ```ts
|
|
900
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
901
|
+
*
|
|
902
|
+
* assertWrap.isObject({}); // returns `{}`
|
|
903
|
+
* assertWrap.isObject([]); // throws an error
|
|
904
|
+
* ```
|
|
905
|
+
*
|
|
906
|
+
* @returns The value if the assertion passes.
|
|
907
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
908
|
+
* @see
|
|
909
|
+
* - {@link assertWrap.isNotFunction} : the opposite assertion.
|
|
910
|
+
*/
|
|
911
|
+
isObject: typeof autoGuardSymbol;
|
|
912
|
+
/**
|
|
913
|
+
* Asserts that a value is a string. Returns the value if the assertion passes.
|
|
914
|
+
*
|
|
915
|
+
* Type guards the value.
|
|
916
|
+
*
|
|
917
|
+
* @example
|
|
918
|
+
*
|
|
919
|
+
* ```ts
|
|
920
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
921
|
+
*
|
|
922
|
+
* assertWrap.isString(''); // returns `''`
|
|
923
|
+
* assertWrap.isString(5); // throws an error
|
|
924
|
+
* ```
|
|
925
|
+
*
|
|
926
|
+
* @returns The value if the assertion passes.
|
|
927
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
928
|
+
* @see
|
|
929
|
+
* - {@link assertWrap.isNotFunction} : the opposite assertion.
|
|
930
|
+
*/
|
|
931
|
+
isString: typeof autoGuardSymbol;
|
|
932
|
+
/**
|
|
933
|
+
* Trying to assign a unique symbol to another variable kills the `unique` part of the
|
|
934
|
+
* symbol. this seems to be a bug with TypeScript itself.
|
|
935
|
+
*
|
|
936
|
+
* For some reason `checkWrap` does not suffer from this issue though.
|
|
937
|
+
*
|
|
938
|
+
* @example Const mySymbol = Symbol('mine'); const mySymbol2 = mySymbol; // this is no
|
|
939
|
+
* longer `unique symbol`
|
|
940
|
+
*/
|
|
941
|
+
/**
|
|
942
|
+
* Asserts that a value is a symbol. Returns the value if the assertion passes.
|
|
943
|
+
*
|
|
944
|
+
* Type guards the value.
|
|
945
|
+
*
|
|
946
|
+
* @example
|
|
947
|
+
*
|
|
948
|
+
* ```ts
|
|
949
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
950
|
+
*
|
|
951
|
+
* assertWrap.isSymbol(Symbol('my-symbol')); // returns the created symbol
|
|
952
|
+
* assertWrap.isSymbol('my-symbol'); // throws an error
|
|
953
|
+
* ```
|
|
954
|
+
*
|
|
955
|
+
* @returns The value if the assertion passes.
|
|
956
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
957
|
+
* @see
|
|
958
|
+
* - {@link assertWrap.isNotFunction} : the opposite assertion.
|
|
169
959
|
*/
|
|
170
960
|
isSymbol: <const Actual>(actual: Actual, failureMessage?: string | undefined) => NarrowToExpected<Actual, symbol>;
|
|
961
|
+
/**
|
|
962
|
+
* Asserts that a value is exactly `undefined. Returns the value if the assertion passes.
|
|
963
|
+
*
|
|
964
|
+
* Type guards the value.
|
|
965
|
+
*
|
|
966
|
+
* @example
|
|
967
|
+
*
|
|
968
|
+
* ```ts
|
|
969
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
970
|
+
*
|
|
971
|
+
* assertWrap.isUndefined(undefined); // returns `undefined`
|
|
972
|
+
* assertWrap.isUndefined(null); // throws an error
|
|
973
|
+
* ```
|
|
974
|
+
*
|
|
975
|
+
* @returns The value if the assertion passes.
|
|
976
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
977
|
+
* @see
|
|
978
|
+
* - {@link assertWrap.isNotFunction} : the opposite assertion.
|
|
979
|
+
*/
|
|
980
|
+
isUndefined: typeof autoGuardSymbol;
|
|
981
|
+
/**
|
|
982
|
+
* Asserts that a value is _not_ an array. Returns the value if the assertion passes.
|
|
983
|
+
*
|
|
984
|
+
* Type guards the value.
|
|
985
|
+
*
|
|
986
|
+
* @example
|
|
987
|
+
*
|
|
988
|
+
* ```ts
|
|
989
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
990
|
+
*
|
|
991
|
+
* assertWrap.isNotArray([]); // throws an error
|
|
992
|
+
* assertWrap.isNotArray({length: 4}); // returns `{length: 4}`
|
|
993
|
+
* ```
|
|
994
|
+
*
|
|
995
|
+
* @returns The value if the assertion passes.
|
|
996
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
997
|
+
* @see
|
|
998
|
+
* - {@link assertWrap.isArray} : the opposite assertion.
|
|
999
|
+
*/
|
|
171
1000
|
isNotArray: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, ReadonlyArray<unknown>>;
|
|
1001
|
+
/**
|
|
1002
|
+
* Asserts that a value is _not_ a BigInt. Returns the value if the assertion passes.
|
|
1003
|
+
*
|
|
1004
|
+
* Type guards the value.
|
|
1005
|
+
*
|
|
1006
|
+
* @example
|
|
1007
|
+
*
|
|
1008
|
+
* ```ts
|
|
1009
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
1010
|
+
*
|
|
1011
|
+
* assertWrap.isNotBigInt(123n); // throws an error
|
|
1012
|
+
* assertWrap.isNotBigInt(123); // returns `123`
|
|
1013
|
+
* ```
|
|
1014
|
+
*
|
|
1015
|
+
* @returns The value if the assertion passes.
|
|
1016
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1017
|
+
* @see
|
|
1018
|
+
* - {@link assertWrap.isBigInt} : the opposite assertion.
|
|
1019
|
+
*/
|
|
172
1020
|
isNotBigInt: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, bigint>;
|
|
1021
|
+
/**
|
|
1022
|
+
* Asserts that a value is _not_ a boolean. Returns the value if the assertion passes.
|
|
1023
|
+
*
|
|
1024
|
+
* Type guards the value.
|
|
1025
|
+
*
|
|
1026
|
+
* @example
|
|
1027
|
+
*
|
|
1028
|
+
* ```ts
|
|
1029
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
1030
|
+
*
|
|
1031
|
+
* assertWrap.isNotBoolean(true); // throws an error
|
|
1032
|
+
* assertWrap.isNotBoolean('true'); // returns `'true'`
|
|
1033
|
+
* ```
|
|
1034
|
+
*
|
|
1035
|
+
* @returns The value if the assertion passes.
|
|
1036
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1037
|
+
* @see
|
|
1038
|
+
* - {@link assertWrap.isBoolean} : the opposite assertion.
|
|
1039
|
+
*/
|
|
173
1040
|
isNotBoolean: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, boolean>;
|
|
1041
|
+
/**
|
|
1042
|
+
* Asserts that a value is _not_ a function. Returns the value if the assertion passes.
|
|
1043
|
+
*
|
|
1044
|
+
* Type guards the value.
|
|
1045
|
+
*
|
|
1046
|
+
* @example
|
|
1047
|
+
*
|
|
1048
|
+
* ```ts
|
|
1049
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
1050
|
+
*
|
|
1051
|
+
* assertWrap.isNotFunction(() => {}); // throws an error
|
|
1052
|
+
* assertWrap.isNotFunction({}); // returns `{}`
|
|
1053
|
+
* ```
|
|
1054
|
+
*
|
|
1055
|
+
* @returns The value if the assertion passes.
|
|
1056
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1057
|
+
* @see
|
|
1058
|
+
* - {@link assertWrap.isFunction} : the opposite assertion.
|
|
1059
|
+
*/
|
|
174
1060
|
isNotFunction: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, AnyFunction>;
|
|
1061
|
+
/**
|
|
1062
|
+
* Asserts that a value is _not_ exactly `null. Returns the value if the assertion passes.
|
|
1063
|
+
*
|
|
1064
|
+
* Type guards the value.
|
|
1065
|
+
*
|
|
1066
|
+
* @example
|
|
1067
|
+
*
|
|
1068
|
+
* ```ts
|
|
1069
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
1070
|
+
*
|
|
1071
|
+
* assertWrap.isNotNull(null); // throws an error
|
|
1072
|
+
* assertWrap.isNotNull(undefined); // returns `undefined`
|
|
1073
|
+
* ```
|
|
1074
|
+
*
|
|
1075
|
+
* @returns The value if the assertion passes.
|
|
1076
|
+
* @throws {@link AssertionError} If the assertion failed. @see
|
|
1077
|
+
* @see
|
|
1078
|
+
* - {@link assertWrap.isFunction} : the opposite assertion.
|
|
1079
|
+
*/
|
|
175
1080
|
isNotNull: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, null>;
|
|
1081
|
+
/**
|
|
1082
|
+
* Asserts that a value is _not_ a number. This includes `NaN. Returns the value if the
|
|
1083
|
+
* assertion passes.
|
|
1084
|
+
*
|
|
1085
|
+
* Type guards the value.
|
|
1086
|
+
*
|
|
1087
|
+
* @example
|
|
1088
|
+
*
|
|
1089
|
+
* ```ts
|
|
1090
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
1091
|
+
*
|
|
1092
|
+
* assertWrap.isNotNumber(123); // throws an error
|
|
1093
|
+
* assertWrap.isNotNumber(123n); // returns `123n`
|
|
1094
|
+
* ```
|
|
1095
|
+
*
|
|
1096
|
+
* @returns The value if the assertion passes.
|
|
1097
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1098
|
+
* @see
|
|
1099
|
+
* - {@link assertWrap.isNotFunction} : the opposite assertion.
|
|
1100
|
+
*/
|
|
176
1101
|
isNotNumber: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, number>;
|
|
1102
|
+
/**
|
|
1103
|
+
* Asserts that a value is _not_ an object. This includes arrays. Returns the value if the
|
|
1104
|
+
* assertion passes.
|
|
1105
|
+
*
|
|
1106
|
+
* Type guards the value.
|
|
1107
|
+
*
|
|
1108
|
+
* @example
|
|
1109
|
+
*
|
|
1110
|
+
* ```ts
|
|
1111
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
1112
|
+
*
|
|
1113
|
+
* assertWrap.isNotObject({}); // throws an error
|
|
1114
|
+
* assertWrap.isNotObject([]); // returns `[]`
|
|
1115
|
+
* ```
|
|
1116
|
+
*
|
|
1117
|
+
* @returns The value if the assertion passes.
|
|
1118
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1119
|
+
* @see
|
|
1120
|
+
* - {@link assertWrap.isFunction} : the opposite assertion.
|
|
1121
|
+
*/
|
|
177
1122
|
isNotObject: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, UnknownObject>;
|
|
1123
|
+
/**
|
|
1124
|
+
* Asserts that a value is _not_ a string. Returns the value if the assertion passes.
|
|
1125
|
+
*
|
|
1126
|
+
* Type guards the value.
|
|
1127
|
+
*
|
|
1128
|
+
* @example
|
|
1129
|
+
*
|
|
1130
|
+
* ```ts
|
|
1131
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
1132
|
+
*
|
|
1133
|
+
* assertWrap.isNotString(''); // throws an error
|
|
1134
|
+
* assertWrap.isNotString(5); // returns `5`
|
|
1135
|
+
* ```
|
|
1136
|
+
*
|
|
1137
|
+
* @returns The value if the assertion passes.
|
|
1138
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1139
|
+
* @see
|
|
1140
|
+
* - {@link assertWrap.isFunction} : the opposite assertion.
|
|
1141
|
+
*/
|
|
178
1142
|
isNotString: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, string>;
|
|
179
|
-
|
|
1143
|
+
/**
|
|
1144
|
+
* Asserts that a value is _not_ a symbol. Returns the value if the assertion passes.
|
|
1145
|
+
*
|
|
1146
|
+
* Type guards the value.
|
|
1147
|
+
*
|
|
1148
|
+
* @example
|
|
1149
|
+
*
|
|
1150
|
+
* ```ts
|
|
1151
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
1152
|
+
*
|
|
1153
|
+
* assertWrap.isNotSymbol(Symbol('my-symbol')); // throws an error
|
|
1154
|
+
* assertWrap.isNotSymbol('my-symbol'); // returns `'my-symbol'`
|
|
1155
|
+
* ```
|
|
1156
|
+
*
|
|
1157
|
+
* @returns The value if the assertion passes.
|
|
1158
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1159
|
+
* @see
|
|
1160
|
+
* - {@link assertWrap.isFunction} : the opposite assertion.
|
|
1161
|
+
*/
|
|
180
1162
|
isNotSymbol: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, symbol>;
|
|
1163
|
+
/**
|
|
1164
|
+
* Asserts that a value is _not_ exactly `undefined. Returns the value if the assertion
|
|
1165
|
+
* passes.
|
|
1166
|
+
*
|
|
1167
|
+
* Type guards the value.
|
|
1168
|
+
*
|
|
1169
|
+
* @example
|
|
1170
|
+
*
|
|
1171
|
+
* ```ts
|
|
1172
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
1173
|
+
*
|
|
1174
|
+
* assertWrap.isNotUndefined(undefined); // throws an error
|
|
1175
|
+
* assertWrap.isNotUndefined(null); // returns `null`
|
|
1176
|
+
* ```
|
|
1177
|
+
*
|
|
1178
|
+
* @returns The value if the assertion passes.
|
|
1179
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1180
|
+
* @see
|
|
1181
|
+
* - {@link assertWrap.isFunction} : the opposite assertion.
|
|
1182
|
+
*/
|
|
1183
|
+
isNotUndefined: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, undefined>;
|
|
181
1184
|
};
|
|
182
|
-
|
|
1185
|
+
checkWrap: {
|
|
1186
|
+
/**
|
|
1187
|
+
* Checks that a value is an array. Returns the value if the check passes, otherwise
|
|
1188
|
+
* `undefined`.
|
|
1189
|
+
*
|
|
1190
|
+
* Type guards the value.
|
|
1191
|
+
*
|
|
1192
|
+
* @example
|
|
1193
|
+
*
|
|
1194
|
+
* ```ts
|
|
1195
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
1196
|
+
*
|
|
1197
|
+
* checkWrap.isArray([]); // returns `[]`
|
|
1198
|
+
* checkWrap.isArray({length: 4}); // returns `undefined`
|
|
1199
|
+
* ```
|
|
1200
|
+
*
|
|
1201
|
+
* @returns The value if the check passes. Otherwise, `undefined`.
|
|
1202
|
+
* @see
|
|
1203
|
+
* - {@link checkWrap.isNotArray} : the opposite check.
|
|
1204
|
+
*/
|
|
1205
|
+
isArray: typeof autoGuardSymbol;
|
|
1206
|
+
/**
|
|
1207
|
+
* Checks that a value is a BigInt. Returns the value if the check passes, otherwise
|
|
1208
|
+
* `undefined`.
|
|
1209
|
+
*
|
|
1210
|
+
* Type guards the value.
|
|
1211
|
+
*
|
|
1212
|
+
* @example
|
|
1213
|
+
*
|
|
1214
|
+
* ```ts
|
|
1215
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
1216
|
+
*
|
|
1217
|
+
* checkWrap.isBigInt(123n); // returns `123n`
|
|
1218
|
+
* checkWrap.isBigInt(123); // returns `undefined`
|
|
1219
|
+
* ```
|
|
1220
|
+
*
|
|
1221
|
+
* @returns The value if the check passes. Otherwise, `undefined`.
|
|
1222
|
+
* @see
|
|
1223
|
+
* - {@link checkWrap.isNotBigInt} : the opposite check.
|
|
1224
|
+
*/
|
|
1225
|
+
isBigInt: typeof autoGuardSymbol;
|
|
1226
|
+
/**
|
|
1227
|
+
* Checks that a value is a boolean. Returns the value if the check passes, otherwise
|
|
1228
|
+
* `undefined`.
|
|
1229
|
+
*
|
|
1230
|
+
* Type guards the value.
|
|
1231
|
+
*
|
|
1232
|
+
* @example
|
|
1233
|
+
*
|
|
1234
|
+
* ```ts
|
|
1235
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
1236
|
+
*
|
|
1237
|
+
* checkWrap.isBoolean(true); // returns `true`
|
|
1238
|
+
* checkWrap.isBoolean('true'); // returns `undefined`
|
|
1239
|
+
* ```
|
|
1240
|
+
*
|
|
1241
|
+
* @returns The value if the check passes. Otherwise, `undefined`.
|
|
1242
|
+
* @see
|
|
1243
|
+
* - {@link checkWrap.isNotBoolean} : the opposite check.
|
|
1244
|
+
*/
|
|
1245
|
+
isBoolean: typeof autoGuardSymbol;
|
|
1246
|
+
/**
|
|
1247
|
+
* Checks that a value is a function. Returns the value if the check passes, otherwise
|
|
1248
|
+
* `undefined`.
|
|
1249
|
+
*
|
|
1250
|
+
* Type guards the value.
|
|
1251
|
+
*
|
|
1252
|
+
* @example
|
|
1253
|
+
*
|
|
1254
|
+
* ```ts
|
|
1255
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
1256
|
+
*
|
|
1257
|
+
* checkWrap.isFunction(() => {}); // returns `() => {}`
|
|
1258
|
+
* checkWrap.isFunction({}); // returns `undefined`
|
|
1259
|
+
* ```
|
|
1260
|
+
*
|
|
1261
|
+
* @returns The value if the check passes. Otherwise, `undefined`.
|
|
1262
|
+
* @see
|
|
1263
|
+
* - {@link checkWrap.isNotFunction} : the opposite check.
|
|
1264
|
+
*/
|
|
183
1265
|
isFunction: <const Actual>(actual: Actual) => NarrowToActual<Actual, AnyFunction> | undefined;
|
|
1266
|
+
/**
|
|
1267
|
+
* Checks that a value is exactly `null. Returns the value if the check passes, otherwise
|
|
1268
|
+
* `undefined`.
|
|
1269
|
+
*
|
|
1270
|
+
* Type guards the value.
|
|
1271
|
+
*
|
|
1272
|
+
* @example
|
|
1273
|
+
*
|
|
1274
|
+
* ```ts
|
|
1275
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
1276
|
+
*
|
|
1277
|
+
* checkWrap.isNull(null); // returns `null`
|
|
1278
|
+
* checkWrap.isNull(undefined); // returns `undefined`
|
|
1279
|
+
* ```
|
|
1280
|
+
*
|
|
1281
|
+
* @returns The value if the check passes. Otherwise, `undefined`.
|
|
1282
|
+
* @see
|
|
1283
|
+
* - {@link checkWrap.isNotFunction} : the opposite check.
|
|
1284
|
+
*/
|
|
1285
|
+
isNull: typeof autoGuardSymbol;
|
|
1286
|
+
/**
|
|
1287
|
+
* Checks that a value is a number. This excludes `NaN. Returns the value if the check
|
|
1288
|
+
* passes, otherwise `undefined`.
|
|
1289
|
+
*
|
|
1290
|
+
* Type guards the value.
|
|
1291
|
+
*
|
|
1292
|
+
* @example
|
|
1293
|
+
*
|
|
1294
|
+
* ```ts
|
|
1295
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
1296
|
+
*
|
|
1297
|
+
* checkWrap.isNumber(123); // returns `123`
|
|
1298
|
+
* checkWrap.isNumber(123n); // returns `undefined`
|
|
1299
|
+
* ```
|
|
1300
|
+
*
|
|
1301
|
+
* @returns The value if the check passes. Otherwise, `undefined`.
|
|
1302
|
+
* @see
|
|
1303
|
+
* - {@link checkWrap.isNotFunction} : the opposite check.
|
|
1304
|
+
*/
|
|
1305
|
+
isNumber: typeof autoGuardSymbol;
|
|
1306
|
+
/**
|
|
1307
|
+
* Checks that a value is an object. This excludes arrays. Returns the value if the check
|
|
1308
|
+
* passes, otherwise `undefined`.
|
|
1309
|
+
*
|
|
1310
|
+
* Type guards the value.
|
|
1311
|
+
*
|
|
1312
|
+
* @example
|
|
1313
|
+
*
|
|
1314
|
+
* ```ts
|
|
1315
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
1316
|
+
*
|
|
1317
|
+
* checkWrap.isObject({}); // returns `{}`
|
|
1318
|
+
* checkWrap.isObject([]); // returns `undefined`
|
|
1319
|
+
* ```
|
|
1320
|
+
*
|
|
1321
|
+
* @returns The value if the check passes. Otherwise, `undefined`.
|
|
1322
|
+
* @see
|
|
1323
|
+
* - {@link checkWrap.isNotFunction} : the opposite check.
|
|
1324
|
+
*/
|
|
1325
|
+
isObject: typeof autoGuardSymbol;
|
|
1326
|
+
/**
|
|
1327
|
+
* Checks that a value is a string. Returns the value if the check passes, otherwise
|
|
1328
|
+
* `undefined`.
|
|
1329
|
+
*
|
|
1330
|
+
* Type guards the value.
|
|
1331
|
+
*
|
|
1332
|
+
* @example
|
|
1333
|
+
*
|
|
1334
|
+
* ```ts
|
|
1335
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
1336
|
+
*
|
|
1337
|
+
* checkWrap.isString(''); // returns `''`
|
|
1338
|
+
* checkWrap.isString(5); // returns `undefined`
|
|
1339
|
+
* ```
|
|
1340
|
+
*
|
|
1341
|
+
* @returns The value if the check passes. Otherwise, `undefined`.
|
|
1342
|
+
* @see
|
|
1343
|
+
* - {@link checkWrap.isNotFunction} : the opposite check.
|
|
1344
|
+
*/
|
|
1345
|
+
isString: typeof autoGuardSymbol;
|
|
1346
|
+
/**
|
|
1347
|
+
* Checks that a value is a symbol. Returns the value if the check passes, otherwise
|
|
1348
|
+
* `undefined`.
|
|
1349
|
+
*
|
|
1350
|
+
* Type guards the value.
|
|
1351
|
+
*
|
|
1352
|
+
* @example
|
|
1353
|
+
*
|
|
1354
|
+
* ```ts
|
|
1355
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
1356
|
+
*
|
|
1357
|
+
* checkWrap.isSymbol(Symbol('my-symbol')); // returns the created symbol
|
|
1358
|
+
* checkWrap.isSymbol('my-symbol'); // returns `undefined`
|
|
1359
|
+
* ```
|
|
1360
|
+
*
|
|
1361
|
+
* @returns The value if the check passes. Otherwise, `undefined`.
|
|
1362
|
+
* @see
|
|
1363
|
+
* - {@link checkWrap.isNotFunction} : the opposite check.
|
|
1364
|
+
*/
|
|
1365
|
+
isSymbol: typeof autoGuardSymbol;
|
|
184
1366
|
/**
|
|
185
1367
|
* It doesn't make any sense for `checkWrap.isUndefined` to exist. If the input is
|
|
186
1368
|
* `undefined`, it returns `undefined`. If the input isn't `undefined`, it still returns
|
|
187
1369
|
* `undefined`.
|
|
188
1370
|
*/
|
|
1371
|
+
/**
|
|
1372
|
+
* Checks that a value is exactly `undefined. Returns the value if the check passes,
|
|
1373
|
+
* otherwise `undefined`.
|
|
1374
|
+
*
|
|
1375
|
+
* Type guards the value.
|
|
1376
|
+
*
|
|
1377
|
+
* @example
|
|
1378
|
+
*
|
|
1379
|
+
* ```ts
|
|
1380
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
1381
|
+
*
|
|
1382
|
+
* checkWrap.isUndefined(undefined); // returns `undefined`
|
|
1383
|
+
* checkWrap.isUndefined(null); // returns `undefined`
|
|
1384
|
+
* ```
|
|
1385
|
+
*
|
|
1386
|
+
* @returns The value if the check passes. Otherwise, `undefined`.
|
|
1387
|
+
* @see
|
|
1388
|
+
* - {@link checkWrap.isNotFunction} : the opposite check.
|
|
1389
|
+
*/
|
|
189
1390
|
isUndefined: undefined;
|
|
190
1391
|
/**
|
|
191
|
-
*
|
|
192
|
-
* `undefined
|
|
1392
|
+
* Checks that a value is _not_ an array. Returns the value if the check passes, otherwise
|
|
1393
|
+
* `undefined`.
|
|
1394
|
+
*
|
|
1395
|
+
* Type guards the value.
|
|
1396
|
+
*
|
|
1397
|
+
* @example
|
|
1398
|
+
*
|
|
1399
|
+
* ```ts
|
|
1400
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
1401
|
+
*
|
|
1402
|
+
* checkWrap.isNotArray([]); // returns `undefined`
|
|
1403
|
+
* checkWrap.isNotArray({length: 4}); // returns `{length: 4}`
|
|
1404
|
+
* ```
|
|
1405
|
+
*
|
|
1406
|
+
* @returns The value if the check passes. Otherwise, `undefined`.
|
|
1407
|
+
* @see
|
|
1408
|
+
* - {@link checkWrap.isArray} : the opposite check.
|
|
193
1409
|
*/
|
|
194
|
-
isNotUndefined: undefined;
|
|
195
1410
|
isNotArray: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, ReadonlyArray<unknown>> | undefined;
|
|
1411
|
+
/**
|
|
1412
|
+
* Checks that a value is _not_ a BigInt. Returns the value if the check passes, otherwise
|
|
1413
|
+
* `undefined`.
|
|
1414
|
+
*
|
|
1415
|
+
* Type guards the value.
|
|
1416
|
+
*
|
|
1417
|
+
* @example
|
|
1418
|
+
*
|
|
1419
|
+
* ```ts
|
|
1420
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
1421
|
+
*
|
|
1422
|
+
* checkWrap.isNotBigInt(123n); // returns `undefined`
|
|
1423
|
+
* checkWrap.isNotBigInt(123); // returns `123`
|
|
1424
|
+
* ```
|
|
1425
|
+
*
|
|
1426
|
+
* @returns The value if the check passes. Otherwise, `undefined`.
|
|
1427
|
+
* @see
|
|
1428
|
+
* - {@link checkWrap.isBigInt} : the opposite check.
|
|
1429
|
+
*/
|
|
196
1430
|
isNotBigInt: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, bigint> | undefined;
|
|
1431
|
+
/**
|
|
1432
|
+
* Checks that a value is _not_ a boolean. Returns the value if the check passes, otherwise
|
|
1433
|
+
* `undefined`.
|
|
1434
|
+
*
|
|
1435
|
+
* Type guards the value.
|
|
1436
|
+
*
|
|
1437
|
+
* @example
|
|
1438
|
+
*
|
|
1439
|
+
* ```ts
|
|
1440
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
1441
|
+
*
|
|
1442
|
+
* checkWrap.isNotBoolean(true); // returns `undefined`
|
|
1443
|
+
* checkWrap.isNotBoolean('true'); // returns `'true'`
|
|
1444
|
+
* ```
|
|
1445
|
+
*
|
|
1446
|
+
* @returns The value if the check passes. Otherwise, `undefined`.
|
|
1447
|
+
* @see
|
|
1448
|
+
* - {@link checkWrap.isBoolean} : the opposite check.
|
|
1449
|
+
*/
|
|
197
1450
|
isNotBoolean: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, boolean> | undefined;
|
|
1451
|
+
/**
|
|
1452
|
+
* Checks that a value is _not_ a function. Returns the value if the check passes, otherwise
|
|
1453
|
+
* `undefined`.
|
|
1454
|
+
*
|
|
1455
|
+
* Type guards the value.
|
|
1456
|
+
*
|
|
1457
|
+
* @example
|
|
1458
|
+
*
|
|
1459
|
+
* ```ts
|
|
1460
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
1461
|
+
*
|
|
1462
|
+
* checkWrap.isNotFunction(() => {}); // returns `undefined`
|
|
1463
|
+
* checkWrap.isNotFunction({}); // returns `{}`
|
|
1464
|
+
* ```
|
|
1465
|
+
*
|
|
1466
|
+
* @returns The value if the check passes. Otherwise, `undefined`.
|
|
1467
|
+
* @see
|
|
1468
|
+
* - {@link checkWrap.isFunction} : the opposite check.
|
|
1469
|
+
*/
|
|
198
1470
|
isNotFunction: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, AnyFunction> | undefined;
|
|
1471
|
+
/**
|
|
1472
|
+
* Checks that a value is _not_ exactly `null. Returns the value if the check passes,
|
|
1473
|
+
* otherwise `undefined`.
|
|
1474
|
+
*
|
|
1475
|
+
* Type guards the value.
|
|
1476
|
+
*
|
|
1477
|
+
* @example
|
|
1478
|
+
*
|
|
1479
|
+
* ```ts
|
|
1480
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
1481
|
+
*
|
|
1482
|
+
* checkWrap.isNotNull(null); // returns `undefined`
|
|
1483
|
+
* checkWrap.isNotNull(undefined); // returns `undefined`
|
|
1484
|
+
* ```
|
|
1485
|
+
*
|
|
1486
|
+
* @returns The value if the check passes. Otherwise, `undefined`.
|
|
1487
|
+
* @see
|
|
1488
|
+
* - {@link checkWrap.isFunction} : the opposite check.
|
|
1489
|
+
*/
|
|
199
1490
|
isNotNull: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, null> | undefined;
|
|
1491
|
+
/**
|
|
1492
|
+
* Checks that a value is _not_ a number. This includes `NaN. Returns the value if the check
|
|
1493
|
+
* passes, otherwise `undefined`.
|
|
1494
|
+
*
|
|
1495
|
+
* Type guards the value.
|
|
1496
|
+
*
|
|
1497
|
+
* @example
|
|
1498
|
+
*
|
|
1499
|
+
* ```ts
|
|
1500
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
1501
|
+
*
|
|
1502
|
+
* checkWrap.isNotNumber(123); // returns `undefined`
|
|
1503
|
+
* checkWrap.isNotNumber(123n); // returns `123n`
|
|
1504
|
+
* ```
|
|
1505
|
+
*
|
|
1506
|
+
* @returns The value if the check passes. Otherwise, `undefined`.
|
|
1507
|
+
* @see
|
|
1508
|
+
* - {@link checkWrap.isNotFunction} : the opposite check.
|
|
1509
|
+
*/
|
|
200
1510
|
isNotNumber: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, number> | undefined;
|
|
1511
|
+
/**
|
|
1512
|
+
* Checks that a value is _not_ an object. This includes arrays. Returns the value if the
|
|
1513
|
+
* check passes, otherwise `undefined`.
|
|
1514
|
+
*
|
|
1515
|
+
* Type guards the value.
|
|
1516
|
+
*
|
|
1517
|
+
* @example
|
|
1518
|
+
*
|
|
1519
|
+
* ```ts
|
|
1520
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
1521
|
+
*
|
|
1522
|
+
* checkWrap.isNotObject({}); // returns `undefined`
|
|
1523
|
+
* checkWrap.isNotObject([]); // returns `[]`
|
|
1524
|
+
* ```
|
|
1525
|
+
*
|
|
1526
|
+
* @returns The value if the check passes. Otherwise, `undefined`.
|
|
1527
|
+
* @see
|
|
1528
|
+
* - {@link checkWrap.isFunction} : the opposite check.
|
|
1529
|
+
*/
|
|
201
1530
|
isNotObject: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, UnknownObject> | undefined;
|
|
1531
|
+
/**
|
|
1532
|
+
* Checks that a value is _not_ a string. Returns the value if the check passes, otherwise
|
|
1533
|
+
* `undefined`.
|
|
1534
|
+
*
|
|
1535
|
+
* Type guards the value.
|
|
1536
|
+
*
|
|
1537
|
+
* @example
|
|
1538
|
+
*
|
|
1539
|
+
* ```ts
|
|
1540
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
1541
|
+
*
|
|
1542
|
+
* checkWrap.isNotString(''); // returns `undefined`
|
|
1543
|
+
* checkWrap.isNotString(5); // returns `5`
|
|
1544
|
+
* ```
|
|
1545
|
+
*
|
|
1546
|
+
* @returns The value if the check passes. Otherwise, `undefined`.
|
|
1547
|
+
* @see
|
|
1548
|
+
* - {@link checkWrap.isFunction} : the opposite check.
|
|
1549
|
+
*/
|
|
202
1550
|
isNotString: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, string> | undefined;
|
|
1551
|
+
/**
|
|
1552
|
+
* Checks that a value is _not_ a symbol. Returns the value if the check passes, otherwise
|
|
1553
|
+
* `undefined`.
|
|
1554
|
+
*
|
|
1555
|
+
* Type guards the value.
|
|
1556
|
+
*
|
|
1557
|
+
* @example
|
|
1558
|
+
*
|
|
1559
|
+
* ```ts
|
|
1560
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
1561
|
+
*
|
|
1562
|
+
* checkWrap.isNotSymbol(Symbol('my-symbol')); // returns `undefined`
|
|
1563
|
+
* checkWrap.checkWrap('my-symbol'); // returns `'my-symbol'`
|
|
1564
|
+
* ```
|
|
1565
|
+
*
|
|
1566
|
+
* @returns The value if the check passes. Otherwise, `undefined`.
|
|
1567
|
+
* @see
|
|
1568
|
+
* - {@link checkWrap.isFunction} : the opposite check.
|
|
1569
|
+
*/
|
|
203
1570
|
isNotSymbol: <const Actual>(actual: Actual, failureMessage?: string | undefined) => Exclude<Actual, symbol> | undefined;
|
|
1571
|
+
/**
|
|
1572
|
+
* It doesn't make any sense for `checkWrap.isNotUndefined` to exist. If the input is not
|
|
1573
|
+
* `undefined`, then it still returns `undefined`.
|
|
1574
|
+
*/
|
|
1575
|
+
isNotUndefined: undefined;
|
|
204
1576
|
};
|
|
205
|
-
|
|
1577
|
+
waitUntil: {
|
|
1578
|
+
/**
|
|
1579
|
+
* Repeatedly calls a callback until its output is an array. Once the callback output
|
|
1580
|
+
* passes, it is returned. If the attempts time out, an error is thrown.
|
|
1581
|
+
*
|
|
1582
|
+
* Type guards the value.
|
|
1583
|
+
*
|
|
1584
|
+
* @example
|
|
1585
|
+
*
|
|
1586
|
+
* ```ts
|
|
1587
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1588
|
+
*
|
|
1589
|
+
* await waitUntil.isArray(() => []); // passes
|
|
1590
|
+
* await waitUntil.isArray(() => {
|
|
1591
|
+
* return {length: 4};
|
|
1592
|
+
* }); // throws an error
|
|
1593
|
+
* ```
|
|
1594
|
+
*
|
|
1595
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1596
|
+
* @see
|
|
1597
|
+
* - {@link waitUntil.isNotArray} : the opposite assertion.
|
|
1598
|
+
*/
|
|
1599
|
+
isArray: typeof autoGuardSymbol;
|
|
1600
|
+
/**
|
|
1601
|
+
* Repeatedly calls a callback until its output is a BigInt. Once the callback output
|
|
1602
|
+
* passes, it is returned. If the attempts time out, an error is thrown.
|
|
1603
|
+
*
|
|
1604
|
+
* Type guards the value.
|
|
1605
|
+
*
|
|
1606
|
+
* @example
|
|
1607
|
+
*
|
|
1608
|
+
* ```ts
|
|
1609
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1610
|
+
*
|
|
1611
|
+
* await waitUntil.isBigInt(() => 123n); // returns `123n`
|
|
1612
|
+
* await waitUntil.isBigInt(() => 123); // throws an error
|
|
1613
|
+
* ```
|
|
1614
|
+
*
|
|
1615
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1616
|
+
* @see
|
|
1617
|
+
* - {@link waitUntil.isNotBigInt} : the opposite assertion.
|
|
1618
|
+
*/
|
|
1619
|
+
isBigInt: typeof autoGuardSymbol;
|
|
1620
|
+
/**
|
|
1621
|
+
* Repeatedly calls a callback until its output is a boolean. Once the callback output
|
|
1622
|
+
* passes, it is returned. If the attempts time out, an error is thrown.
|
|
1623
|
+
*
|
|
1624
|
+
* Type guards the value.
|
|
1625
|
+
*
|
|
1626
|
+
* @example
|
|
1627
|
+
*
|
|
1628
|
+
* ```ts
|
|
1629
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1630
|
+
*
|
|
1631
|
+
* await waitUntil.isBoolean(() => true); // returns `true`
|
|
1632
|
+
* await waitUntil.isBoolean(() => 'true'); // throws an error
|
|
1633
|
+
* ```
|
|
1634
|
+
*
|
|
1635
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1636
|
+
* @see
|
|
1637
|
+
* - {@link waitUntil.isNotBoolean} : the opposite assertion.
|
|
1638
|
+
*/
|
|
1639
|
+
isBoolean: typeof autoGuardSymbol;
|
|
1640
|
+
/**
|
|
1641
|
+
* Repeatedly calls a callback until its output is a function. Once the callback output
|
|
1642
|
+
* passes, it is returned. If the attempts time out, an error is thrown.
|
|
1643
|
+
*
|
|
1644
|
+
* Type guards the value.
|
|
1645
|
+
*
|
|
1646
|
+
* @example
|
|
1647
|
+
*
|
|
1648
|
+
* ```ts
|
|
1649
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1650
|
+
*
|
|
1651
|
+
* await waitUntil.isFunction(() => () => {
|
|
1652
|
+
* return {};
|
|
1653
|
+
* }); // returns `{}`
|
|
1654
|
+
* await waitUntil.isFunction(() => {
|
|
1655
|
+
* return {};
|
|
1656
|
+
* }); // throws an error
|
|
1657
|
+
* ```
|
|
1658
|
+
*
|
|
1659
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1660
|
+
* @see
|
|
1661
|
+
* - {@link waitUntil.isNotFunction} : the opposite assertion.
|
|
1662
|
+
*/
|
|
206
1663
|
isFunction: <const Actual>(callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<NarrowToActual<Actual, AnyFunction>>;
|
|
1664
|
+
/**
|
|
1665
|
+
* Repeatedly calls a callback until its output is exactly `null`. Once the callback output
|
|
1666
|
+
* passes, it is returned. If the attempts time out, an error is thrown.
|
|
1667
|
+
*
|
|
1668
|
+
* Type guards the value.
|
|
1669
|
+
*
|
|
1670
|
+
* @example
|
|
1671
|
+
*
|
|
1672
|
+
* ```ts
|
|
1673
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1674
|
+
*
|
|
1675
|
+
* await waitUntil.isNull(() => null); // returns `null`
|
|
1676
|
+
* await waitUntil.isNull(() => undefined); // throws an error
|
|
1677
|
+
* ```
|
|
1678
|
+
*
|
|
1679
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1680
|
+
* @see
|
|
1681
|
+
* - {@link waitUntil.isNotFunction} : the opposite assertion.
|
|
1682
|
+
*/
|
|
1683
|
+
isNull: typeof autoGuardSymbol;
|
|
1684
|
+
/**
|
|
1685
|
+
* Repeatedly calls a callback until its output is a number. This excludes `NaN`. Once the
|
|
1686
|
+
* callback output passes, it is returned. If the attempts time out, an error is thrown.
|
|
1687
|
+
*
|
|
1688
|
+
* Type guards the value.
|
|
1689
|
+
*
|
|
1690
|
+
* @example
|
|
1691
|
+
*
|
|
1692
|
+
* ```ts
|
|
1693
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1694
|
+
*
|
|
1695
|
+
* await waitUntil.isNumber(() => 123); // returns `123`
|
|
1696
|
+
* await waitUntil.isNumber(() => 123n); // throws an error
|
|
1697
|
+
* ```
|
|
1698
|
+
*
|
|
1699
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1700
|
+
* @see
|
|
1701
|
+
* - {@link waitUntil.isNotFunction} : the opposite assertion.
|
|
1702
|
+
*/
|
|
1703
|
+
isNumber: typeof autoGuardSymbol;
|
|
1704
|
+
/**
|
|
1705
|
+
* Repeatedly calls a callback until its output is an object. This excludes arrays. Once the
|
|
1706
|
+
* callback output passes, it is returned. If the attempts time out, an error is thrown.
|
|
1707
|
+
*
|
|
1708
|
+
* Type guards the value.
|
|
1709
|
+
*
|
|
1710
|
+
* @example
|
|
1711
|
+
*
|
|
1712
|
+
* ```ts
|
|
1713
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1714
|
+
*
|
|
1715
|
+
* await waitUntil.isObject(() => {
|
|
1716
|
+
* return {};
|
|
1717
|
+
* }); // returns `{}`
|
|
1718
|
+
* await waitUntil.isObject(() => []); // throws an error
|
|
1719
|
+
* ```
|
|
1720
|
+
*
|
|
1721
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1722
|
+
* @see
|
|
1723
|
+
* - {@link waitUntil.isNotFunction} : the opposite assertion.
|
|
1724
|
+
*/
|
|
1725
|
+
isObject: typeof autoGuardSymbol;
|
|
1726
|
+
/**
|
|
1727
|
+
* Repeatedly calls a callback until its output is a string. Once the callback output
|
|
1728
|
+
* passes, it is returned. If the attempts time out, an error is thrown.
|
|
1729
|
+
*
|
|
1730
|
+
* Type guards the value.
|
|
1731
|
+
*
|
|
1732
|
+
* @example
|
|
1733
|
+
*
|
|
1734
|
+
* ```ts
|
|
1735
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1736
|
+
*
|
|
1737
|
+
* await waitUntil.isString(() => ''); // returns `''`
|
|
1738
|
+
* await waitUntil.isString(() => 5); // throws an error
|
|
1739
|
+
* ```
|
|
1740
|
+
*
|
|
1741
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1742
|
+
* @see
|
|
1743
|
+
* - {@link waitUntil.isNotFunction} : the opposite assertion.
|
|
1744
|
+
*/
|
|
1745
|
+
isString: typeof autoGuardSymbol;
|
|
1746
|
+
/**
|
|
1747
|
+
* Repeatedly calls a callback until its output is a symbol. Once the callback output
|
|
1748
|
+
* passes, it is returned. If the attempts time out, an error is thrown.
|
|
1749
|
+
*
|
|
1750
|
+
* Type guards the value.
|
|
1751
|
+
*
|
|
1752
|
+
* @example
|
|
1753
|
+
*
|
|
1754
|
+
* ```ts
|
|
1755
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1756
|
+
*
|
|
1757
|
+
* await waitUntil.isSymbol(() => Symbol('my-symbol')); // returns the created symbol
|
|
1758
|
+
* await waitUntil.isSymbol(() => 'my-symbol'); // throws an error
|
|
1759
|
+
* ```
|
|
1760
|
+
*
|
|
1761
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1762
|
+
* @see
|
|
1763
|
+
* - {@link waitUntil.isNotFunction} : the opposite assertion.
|
|
1764
|
+
*/
|
|
1765
|
+
isSymbol: typeof autoGuardSymbol;
|
|
1766
|
+
/**
|
|
1767
|
+
* Repeatedly calls a callback until its output is exactly `undefined`. Once the callback
|
|
1768
|
+
* output passes, it is returned. If the attempts time out, an error is thrown.
|
|
1769
|
+
*
|
|
1770
|
+
* Type guards the value.
|
|
1771
|
+
*
|
|
1772
|
+
* @example
|
|
1773
|
+
*
|
|
1774
|
+
* ```ts
|
|
1775
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1776
|
+
*
|
|
1777
|
+
* await waitUntil.isUndefined(() => undefined); // returns `undefined`
|
|
1778
|
+
* await waitUntil.isUndefined(() => null); // throws an error
|
|
1779
|
+
* ```
|
|
1780
|
+
*
|
|
1781
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1782
|
+
* @see
|
|
1783
|
+
* - {@link waitUntil.isNotFunction} : the opposite assertion.
|
|
1784
|
+
*/
|
|
1785
|
+
isUndefined: typeof autoGuardSymbol;
|
|
1786
|
+
/**
|
|
1787
|
+
* Repeatedly calls a callback until its output is _not_ an array. Once the callback output
|
|
1788
|
+
* passes, it is returned. If the attempts time out, an error is thrown.
|
|
1789
|
+
*
|
|
1790
|
+
* Type guards the value.
|
|
1791
|
+
*
|
|
1792
|
+
* @example
|
|
1793
|
+
*
|
|
1794
|
+
* ```ts
|
|
1795
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1796
|
+
*
|
|
1797
|
+
* await waitUntil.isNotArray(() => []); // throws an error
|
|
1798
|
+
* await waitUntil.isNotArray(() => {
|
|
1799
|
+
* return {length: 4};
|
|
1800
|
+
* }); // returns `{length: 4}`
|
|
1801
|
+
* ```
|
|
1802
|
+
*
|
|
1803
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1804
|
+
* @see
|
|
1805
|
+
* - {@link waitUntil.isArray} : the opposite assertion.
|
|
1806
|
+
*/
|
|
207
1807
|
isNotArray: <const Actual>(callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, ReadonlyArray<unknown>>>;
|
|
1808
|
+
/**
|
|
1809
|
+
* Repeatedly calls a callback until its output is _not_ a BigInt. Once the callback output
|
|
1810
|
+
* passes, it is returned. If the attempts time out, an error is thrown.
|
|
1811
|
+
*
|
|
1812
|
+
* Type guards the value.
|
|
1813
|
+
*
|
|
1814
|
+
* @example
|
|
1815
|
+
*
|
|
1816
|
+
* ```ts
|
|
1817
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1818
|
+
*
|
|
1819
|
+
* await waitUntil.isNotBigInt(() => 123n); // throws an error
|
|
1820
|
+
* await waitUntil.isNotBigInt(() => 123); // returns `123`
|
|
1821
|
+
* ```
|
|
1822
|
+
*
|
|
1823
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1824
|
+
* @see
|
|
1825
|
+
* - {@link waitUntil.isBigInt} : the opposite assertion.
|
|
1826
|
+
*/
|
|
208
1827
|
isNotBigInt: <const Actual>(callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, bigint>>;
|
|
1828
|
+
/**
|
|
1829
|
+
* Repeatedly calls a callback until its output is _not_ a boolean. Once the callback output
|
|
1830
|
+
* passes, it is returned. If the attempts time out, an error is thrown.
|
|
1831
|
+
*
|
|
1832
|
+
* Type guards the value.
|
|
1833
|
+
*
|
|
1834
|
+
* @example
|
|
1835
|
+
*
|
|
1836
|
+
* ```ts
|
|
1837
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1838
|
+
*
|
|
1839
|
+
* await waitUntil.isNotBoolean(() => true); // throws an error
|
|
1840
|
+
* await waitUntil.isNotBoolean(() => 'true'); // returns `'true'`
|
|
1841
|
+
* ```
|
|
1842
|
+
*
|
|
1843
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1844
|
+
* @see
|
|
1845
|
+
* - {@link waitUntil.isBoolean} : the opposite assertion.
|
|
1846
|
+
*/
|
|
209
1847
|
isNotBoolean: <const Actual>(callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, boolean>>;
|
|
1848
|
+
/**
|
|
1849
|
+
* Repeatedly calls a callback until its output is _not_ a function. Once the callback
|
|
1850
|
+
* output passes, it is returned. If the attempts time out, an error is thrown.
|
|
1851
|
+
*
|
|
1852
|
+
* Type guards the value.
|
|
1853
|
+
*
|
|
1854
|
+
* @example
|
|
1855
|
+
*
|
|
1856
|
+
* ```ts
|
|
1857
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1858
|
+
*
|
|
1859
|
+
* await waitUntil.isNotFunction(() => () => {
|
|
1860
|
+
* return {};
|
|
1861
|
+
* }); // throws an error
|
|
1862
|
+
* await waitUntil.isNotFunction(() => {
|
|
1863
|
+
* return {};
|
|
1864
|
+
* }); // returns `{}`
|
|
1865
|
+
* ```
|
|
1866
|
+
*
|
|
1867
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1868
|
+
* @see
|
|
1869
|
+
* - {@link waitUntil.isFunction} : the opposite assertion.
|
|
1870
|
+
*/
|
|
210
1871
|
isNotFunction: <const Actual>(callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, AnyFunction>>;
|
|
1872
|
+
/**
|
|
1873
|
+
* Repeatedly calls a callback until its output is _not_ exactly `null`. Once the callback
|
|
1874
|
+
* output passes, it is returned. If the attempts time out, an error is thrown.
|
|
1875
|
+
*
|
|
1876
|
+
* Type guards the value.
|
|
1877
|
+
*
|
|
1878
|
+
* @example
|
|
1879
|
+
*
|
|
1880
|
+
* ```ts
|
|
1881
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1882
|
+
*
|
|
1883
|
+
* await waitUntil.isNotNull(() => null); // throws an error
|
|
1884
|
+
* await waitUntil.isNotNull(() => undefined); // returns `undefined`
|
|
1885
|
+
* ```
|
|
1886
|
+
*
|
|
1887
|
+
* @throws {@link AssertionError} If the assertion failed. @see
|
|
1888
|
+
* @see
|
|
1889
|
+
* - {@link waitUntil.isFunction} : the opposite assertion.
|
|
1890
|
+
*/
|
|
211
1891
|
isNotNull: <const Actual>(callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, null>>;
|
|
1892
|
+
/**
|
|
1893
|
+
* Repeatedly calls a callback until its output is _not_ a number. This includes `NaN`. Once
|
|
1894
|
+
* the callback output passes, it is returned. If the attempts time out, an error is
|
|
1895
|
+
* thrown.
|
|
1896
|
+
*
|
|
1897
|
+
* Type guards the value.
|
|
1898
|
+
*
|
|
1899
|
+
* @example
|
|
1900
|
+
*
|
|
1901
|
+
* ```ts
|
|
1902
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1903
|
+
*
|
|
1904
|
+
* await waitUntil.isNotNumber(() => 123); // throws an error
|
|
1905
|
+
* await waitUntil.isNotNumber(() => 123n); // returns `123n`
|
|
1906
|
+
* ```
|
|
1907
|
+
*
|
|
1908
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1909
|
+
* @see
|
|
1910
|
+
* - {@link waitUntil.isNotFunction} : the opposite assertion.
|
|
1911
|
+
*/
|
|
212
1912
|
isNotNumber: <const Actual>(callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, number>>;
|
|
1913
|
+
/**
|
|
1914
|
+
* Repeatedly calls a callback until its output is _not_ an object. This includes arrays.
|
|
1915
|
+
* Once the callback output passes, it is returned. If the attempts time out, an error is
|
|
1916
|
+
* thrown.
|
|
1917
|
+
*
|
|
1918
|
+
* Type guards the value.
|
|
1919
|
+
*
|
|
1920
|
+
* @example
|
|
1921
|
+
*
|
|
1922
|
+
* ```ts
|
|
1923
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1924
|
+
*
|
|
1925
|
+
* await waitUntil.isNotObject(() => {
|
|
1926
|
+
* return {};
|
|
1927
|
+
* }); // throws an error
|
|
1928
|
+
* await waitUntil.isNotObject(() => []); // returns `[]`
|
|
1929
|
+
* ```
|
|
1930
|
+
*
|
|
1931
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1932
|
+
* @see
|
|
1933
|
+
* - {@link waitUntil.isFunction} : the opposite assertion.
|
|
1934
|
+
*/
|
|
213
1935
|
isNotObject: <const Actual>(callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, UnknownObject>>;
|
|
1936
|
+
/**
|
|
1937
|
+
* Repeatedly calls a callback until its output is _not_ a string. Once the callback output
|
|
1938
|
+
* passes, it is returned. If the attempts time out, an error is thrown.
|
|
1939
|
+
*
|
|
1940
|
+
* Type guards the value.
|
|
1941
|
+
*
|
|
1942
|
+
* @example
|
|
1943
|
+
*
|
|
1944
|
+
* ```ts
|
|
1945
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1946
|
+
*
|
|
1947
|
+
* await waitUntil.isNotString(() => ''); // throws an error
|
|
1948
|
+
* await waitUntil.isNotString(() => 5); // returns `5`
|
|
1949
|
+
* ```
|
|
1950
|
+
*
|
|
1951
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1952
|
+
* @see
|
|
1953
|
+
* - {@link waitUntil.isFunction} : the opposite assertion.
|
|
1954
|
+
*/
|
|
214
1955
|
isNotString: <const Actual>(callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, string>>;
|
|
215
|
-
|
|
1956
|
+
/**
|
|
1957
|
+
* Repeatedly calls a callback until its output is _not_ a symbol. Once the callback output
|
|
1958
|
+
* passes, it is returned. If the attempts time out, an error is thrown.
|
|
1959
|
+
*
|
|
1960
|
+
* Type guards the value.
|
|
1961
|
+
*
|
|
1962
|
+
* @example
|
|
1963
|
+
*
|
|
1964
|
+
* ```ts
|
|
1965
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1966
|
+
*
|
|
1967
|
+
* await waitUntil.isNotSymbol(() => Symbol('my-symbol')); // throws an error
|
|
1968
|
+
* await waitUntil.isNotSymbol(() => 'my-symbol'); // returns `'my-symbol'`
|
|
1969
|
+
* ```
|
|
1970
|
+
*
|
|
1971
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1972
|
+
* @see
|
|
1973
|
+
* - {@link waitUntil.isFunction} : the opposite assertion.
|
|
1974
|
+
*/
|
|
216
1975
|
isNotSymbol: <const Actual>(callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, symbol>>;
|
|
1976
|
+
/**
|
|
1977
|
+
* Repeatedly calls a callback until its output is _not_ exactly `undefined`. Once the
|
|
1978
|
+
* callback output passes, it is returned. If the attempts time out, an error is thrown.
|
|
1979
|
+
*
|
|
1980
|
+
* Type guards the value.
|
|
1981
|
+
*
|
|
1982
|
+
* @example
|
|
1983
|
+
*
|
|
1984
|
+
* ```ts
|
|
1985
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
1986
|
+
*
|
|
1987
|
+
* await waitUntil.isNotUndefined(() => undefined); // throws an error
|
|
1988
|
+
* await waitUntil.isNotUndefined(() => null); // returns `null`
|
|
1989
|
+
* ```
|
|
1990
|
+
*
|
|
1991
|
+
* @throws {@link AssertionError} If the assertion failed.
|
|
1992
|
+
* @see
|
|
1993
|
+
* - {@link waitUntil.isFunction} : the opposite assertion.
|
|
1994
|
+
*/
|
|
1995
|
+
isNotUndefined: <const Actual>(callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, undefined>>;
|
|
217
1996
|
};
|
|
218
1997
|
};
|
|
219
1998
|
/**
|
|
@@ -224,7 +2003,8 @@ export declare const runtimeTypeGuards: {
|
|
|
224
2003
|
* both distinct from `object`.
|
|
225
2004
|
*
|
|
226
2005
|
* @category Assert : Util
|
|
227
|
-
* @
|
|
2006
|
+
* @category Package : @augment-vir/assert
|
|
2007
|
+
* @package [`@augment-vir/assert`](https://www.npmjs.com/package/@augment-vir/assert)
|
|
228
2008
|
*/
|
|
229
2009
|
export declare enum RuntimeType {
|
|
230
2010
|
String = "string",
|
|
@@ -259,6 +2039,7 @@ export declare enum RuntimeType {
|
|
|
259
2039
|
* from `object`.
|
|
260
2040
|
*
|
|
261
2041
|
* @category Assert : Util
|
|
2042
|
+
* @category Package : @augment-vir/assert
|
|
262
2043
|
* @example
|
|
263
2044
|
*
|
|
264
2045
|
* ```ts
|
|
@@ -268,7 +2049,7 @@ export declare enum RuntimeType {
|
|
|
268
2049
|
* getRuntimeType({a: 'a'}); // RuntimeType.Object
|
|
269
2050
|
* ```
|
|
270
2051
|
*
|
|
271
|
-
* @package
|
|
2052
|
+
* @package [`@augment-vir/assert`](https://www.npmjs.com/package/@augment-vir/assert)
|
|
272
2053
|
*/
|
|
273
2054
|
export declare function getRuntimeType(actual: unknown): RuntimeType;
|
|
274
2055
|
export {};
|