@augment-vir/assert 30.8.4 → 31.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/dist/assertions/boolean.d.ts +20 -26
- package/dist/assertions/boolean.js +185 -41
- package/dist/assertions/boundary.d.ts +40 -256
- package/dist/assertions/boundary.js +265 -229
- package/dist/assertions/enum.d.ts +12 -13
- package/dist/assertions/enum.js +98 -20
- package/dist/assertions/equality/entry-equality.d.ts +11 -15
- package/dist/assertions/equality/entry-equality.js +210 -43
- package/dist/assertions/equality/json-equality.d.ts +11 -15
- package/dist/assertions/equality/json-equality.js +144 -43
- package/dist/assertions/equality/simple-equality.d.ts +39 -46
- package/dist/assertions/equality/simple-equality.js +316 -61
- package/dist/assertions/extendable-assertions.d.ts +0 -12
- package/dist/assertions/extendable-assertions.js +0 -12
- package/dist/assertions/http.d.ts +10 -14
- package/dist/assertions/http.js +96 -28
- package/dist/assertions/instance.d.ts +10 -18
- package/dist/assertions/instance.js +92 -26
- package/dist/assertions/keys.d.ts +59 -138
- package/dist/assertions/keys.js +279 -163
- package/dist/assertions/length.d.ts +30 -212
- package/dist/assertions/length.js +117 -175
- package/dist/assertions/nullish.d.ts +8 -20
- package/dist/assertions/nullish.js +85 -27
- package/dist/assertions/numeric.d.ts +67 -81
- package/dist/assertions/numeric.js +564 -133
- package/dist/assertions/output.d.ts +2 -3
- package/dist/assertions/output.js +1 -7
- package/dist/assertions/primitive.d.ts +33 -40
- package/dist/assertions/primitive.js +232 -66
- package/dist/assertions/promise.d.ts +20 -30
- package/dist/assertions/promise.js +244 -53
- package/dist/assertions/regexp.d.ts +12 -14
- package/dist/assertions/regexp.js +84 -21
- package/dist/assertions/runtime-type.d.ts +99 -207
- package/dist/assertions/runtime-type.js +805 -276
- package/dist/assertions/throws.d.ts +24 -25
- package/dist/assertions/throws.js +43 -5
- package/dist/assertions/uuid.d.ts +11 -16
- package/dist/assertions/uuid.js +91 -22
- package/dist/assertions/values.d.ts +81 -210
- package/dist/assertions/values.js +627 -234
- package/dist/augments/assertion-exports.d.ts +0 -1
- package/dist/augments/assertion-exports.js +1 -1
- package/dist/augments/guards/assert-wrap.d.ts +7 -4
- package/dist/augments/guards/assert-wrap.js +5 -4
- package/dist/augments/guards/check-wrap.d.ts +7 -5
- package/dist/augments/guards/check-wrap.js +5 -4
- package/dist/augments/guards/check.d.ts +5 -5
- package/dist/augments/guards/check.js +5 -4
- package/dist/augments/guards/wait-until.d.ts +8 -4
- package/dist/augments/guards/wait-until.js +7 -8
- package/dist/guard-types/guard-group.d.ts +5 -2
- package/dist/guard-types/wait-until-function.d.ts +2 -10
- package/dist/guard-types/wait-until-function.js +1 -9
- package/dist/index.d.ts +1 -0
- package/package.json +2 -2
- package/dist/guard-types/assert-wrap-function.d.ts +0 -12
- package/dist/guard-types/assert-wrap-function.js +0 -14
- package/dist/guard-types/check-function.d.ts +0 -14
- package/dist/guard-types/check-function.js +0 -22
- package/dist/guard-types/check-wrap-wrapper-function.d.ts +0 -12
- package/dist/guard-types/check-wrap-wrapper-function.js +0 -19
- package/dist/guard-types/guard-override.d.ts +0 -4
- package/dist/guard-types/guard-override.js +0 -10
|
@@ -1,45 +1,119 @@
|
|
|
1
1
|
import { stringify } from '@augment-vir/core';
|
|
2
2
|
import { AssertionError } from '../augments/assertion.error.js';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
function isPrimitive(input, failureMessage) {
|
|
3
|
+
import { createWaitUntil } from '../guard-types/wait-until-function.js';
|
|
4
|
+
const assertions = {
|
|
6
5
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Asserts that a value is a valid `PropertyKey`. `PropertyKey` is a built-in TypeScript type
|
|
7
|
+
* which refers to all possible key types for a JavaScript object.
|
|
8
|
+
*
|
|
9
|
+
* Type guards the value.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import {assert} from '@augment-vir/assert';
|
|
15
|
+
*
|
|
16
|
+
* assert.isPropertyKey('key'); // passes
|
|
17
|
+
* assert.isPropertyKey(true); // fails
|
|
18
|
+
* assert.isPropertyKey({}); // fails
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
22
|
+
* @see
|
|
23
|
+
* - {@link assert.isNotPropertyKey} : the opposite assertion.
|
|
9
24
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
25
|
+
isPropertyKey(actual, failureMessage) {
|
|
26
|
+
if (typeof actual !== 'string' &&
|
|
27
|
+
typeof actual !== 'number' &&
|
|
28
|
+
typeof actual !== 'symbol') {
|
|
29
|
+
throw new AssertionError(`'${stringify(actual)}' is not a PropertyKey.`, failureMessage);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* Asserts that a value is _not_ a valid `PropertyKey`. `PropertyKey` is a built-in TypeScript
|
|
34
|
+
* type which refers to all possible key types for a JavaScript object.
|
|
35
|
+
*
|
|
36
|
+
* Type guards the value.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* import {assert} from '@augment-vir/assert';
|
|
42
|
+
*
|
|
43
|
+
* assert.isNotPropertyKey('key'); // fails
|
|
44
|
+
* assert.isNotPropertyKey(true); // passes
|
|
45
|
+
* assert.isNotPropertyKey({}); // passes
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
49
|
+
* @see
|
|
50
|
+
* - {@link assert.isPropertyKey} : the opposite assertion.
|
|
51
|
+
*/
|
|
52
|
+
isNotPropertyKey(actual, failureMessage) {
|
|
53
|
+
if (typeof actual === 'string' ||
|
|
54
|
+
typeof actual === 'number' ||
|
|
55
|
+
typeof actual === 'symbol') {
|
|
56
|
+
throw new AssertionError(`'${stringify(actual)}' is a PropertyKey.`, failureMessage);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* Asserts that a value is a JavaScript
|
|
61
|
+
* [primitive](https://developer.mozilla.org/docs/Glossary/Primitive).
|
|
62
|
+
*
|
|
63
|
+
* Type guards the value.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
*
|
|
67
|
+
* ```ts
|
|
68
|
+
* import {assert} from '@augment-vir/assert';
|
|
69
|
+
*
|
|
70
|
+
* assert.isPrimitive('key'); // passes
|
|
71
|
+
* assert.isPrimitive(true); // passes
|
|
72
|
+
* assert.isPrimitive({}); // fails
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
76
|
+
* @see
|
|
77
|
+
* - {@link assert.isNotPrimitive} : the opposite assertion.
|
|
78
|
+
*/
|
|
79
|
+
isPrimitive(actual, failureMessage) {
|
|
80
|
+
/**
|
|
81
|
+
* `null` is a primitive but `typeof null` gives `'object'` so we have to special case
|
|
82
|
+
* `null` here.
|
|
83
|
+
*/
|
|
84
|
+
if (actual !== null && (typeof actual === 'object' || typeof actual === 'function')) {
|
|
85
|
+
throw new AssertionError(`'${stringify(actual)}' is not a Primitive.`, failureMessage);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
/**
|
|
89
|
+
* Asserts that a value is _not_ a JavaScript
|
|
90
|
+
* [primitive](https://developer.mozilla.org/docs/Glossary/Primitive).
|
|
91
|
+
*
|
|
92
|
+
* Type guards the value.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
*
|
|
96
|
+
* ```ts
|
|
97
|
+
* import {assert} from '@augment-vir/assert';
|
|
98
|
+
*
|
|
99
|
+
* assert.isPrimitive('key'); // fails
|
|
100
|
+
* assert.isPrimitive(true); // fails
|
|
101
|
+
* assert.isPrimitive({}); // passes
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
105
|
+
* @see
|
|
106
|
+
* - {@link assert.isPrimitive} : the opposite assertion.
|
|
107
|
+
*/
|
|
108
|
+
isNotPrimitive(actual, failureMessage) {
|
|
109
|
+
/**
|
|
110
|
+
* `null` is a primitive but `typeof null` gives `'object'` so we have to special case
|
|
111
|
+
* `null` here.
|
|
112
|
+
*/
|
|
113
|
+
if (actual === null || (typeof actual !== 'object' && typeof actual !== 'function')) {
|
|
114
|
+
throw new AssertionError(`'${stringify(actual)}' is not a Primitive.`, failureMessage);
|
|
115
|
+
}
|
|
116
|
+
},
|
|
43
117
|
};
|
|
44
118
|
export const primitiveGuards = {
|
|
45
119
|
assert: assertions,
|
|
@@ -55,15 +129,21 @@ export const primitiveGuards = {
|
|
|
55
129
|
* ```ts
|
|
56
130
|
* import {check} from '@augment-vir/assert';
|
|
57
131
|
*
|
|
58
|
-
* check.
|
|
59
|
-
* check.
|
|
60
|
-
* check.
|
|
132
|
+
* check.isNotPrimitive('key'); // returns `false`
|
|
133
|
+
* check.isNotPrimitive(true); // returns `false`
|
|
134
|
+
* check.isNotPrimitive({}); // returns `true`
|
|
61
135
|
* ```
|
|
62
136
|
*
|
|
63
137
|
* @see
|
|
64
|
-
* - {@link check.
|
|
138
|
+
* - {@link check.isPrimitive} : the opposite check.
|
|
65
139
|
*/
|
|
66
|
-
isNotPrimitive
|
|
140
|
+
isNotPrimitive(actual) {
|
|
141
|
+
/**
|
|
142
|
+
* `null` is a primitive but `typeof null` gives `'object'` so we have to special case
|
|
143
|
+
* `null` here.
|
|
144
|
+
*/
|
|
145
|
+
return actual !== null && (typeof actual === 'object' || typeof actual === 'function');
|
|
146
|
+
},
|
|
67
147
|
/**
|
|
68
148
|
* Checks that a value is _not_ a valid `PropertyKey`. `PropertyKey` is a built-in
|
|
69
149
|
* TypeScript type which refers to all possible key types for a JavaScript object.
|
|
@@ -83,7 +163,11 @@ export const primitiveGuards = {
|
|
|
83
163
|
* @see
|
|
84
164
|
* - {@link check.isPropertyKey} : the opposite check.
|
|
85
165
|
*/
|
|
86
|
-
isNotPropertyKey
|
|
166
|
+
isNotPropertyKey(actual) {
|
|
167
|
+
return (typeof actual !== 'string' &&
|
|
168
|
+
typeof actual !== 'number' &&
|
|
169
|
+
typeof actual !== 'symbol');
|
|
170
|
+
},
|
|
87
171
|
/**
|
|
88
172
|
* Checks that a value is a JavaScript
|
|
89
173
|
* [primitive](https://developer.mozilla.org/docs/Glossary/Primitive).
|
|
@@ -103,7 +187,13 @@ export const primitiveGuards = {
|
|
|
103
187
|
* @see
|
|
104
188
|
* - {@link check.isNotPrimitive} : the opposite check.
|
|
105
189
|
*/
|
|
106
|
-
isPrimitive
|
|
190
|
+
isPrimitive(actual) {
|
|
191
|
+
/**
|
|
192
|
+
* `null` is a primitive but `typeof null` gives `'object'` so we have to special case
|
|
193
|
+
* `null` here.
|
|
194
|
+
*/
|
|
195
|
+
return actual === null || (typeof actual !== 'object' && typeof actual !== 'function');
|
|
196
|
+
},
|
|
107
197
|
/**
|
|
108
198
|
* Checks that a value is _not_ a JavaScript
|
|
109
199
|
* [primitive](https://developer.mozilla.org/docs/Glossary/Primitive).
|
|
@@ -115,15 +205,19 @@ export const primitiveGuards = {
|
|
|
115
205
|
* ```ts
|
|
116
206
|
* import {check} from '@augment-vir/assert';
|
|
117
207
|
*
|
|
118
|
-
* check.
|
|
119
|
-
* check.
|
|
120
|
-
* check.
|
|
208
|
+
* check.isPropertyKey('key'); // returns `true`
|
|
209
|
+
* check.isPropertyKey(true); // returns `false`
|
|
210
|
+
* check.isPropertyKey({}); // returns `false`
|
|
121
211
|
* ```
|
|
122
212
|
*
|
|
123
213
|
* @see
|
|
124
|
-
* - {@link check.
|
|
214
|
+
* - {@link check.isNotPropertyKey} : the opposite check.
|
|
125
215
|
*/
|
|
126
|
-
isPropertyKey
|
|
216
|
+
isPropertyKey(actual) {
|
|
217
|
+
return (typeof actual === 'string' ||
|
|
218
|
+
typeof actual === 'number' ||
|
|
219
|
+
typeof actual === 'symbol');
|
|
220
|
+
},
|
|
127
221
|
},
|
|
128
222
|
assertWrap: {
|
|
129
223
|
/**
|
|
@@ -148,7 +242,16 @@ export const primitiveGuards = {
|
|
|
148
242
|
* @see
|
|
149
243
|
* - {@link assertWrap.isNotPropertyKey} : the opposite assertion.
|
|
150
244
|
*/
|
|
151
|
-
isNotPrimitive
|
|
245
|
+
isNotPrimitive(actual, failureMessage) {
|
|
246
|
+
/**
|
|
247
|
+
* `null` is a primitive but `typeof null` gives `'object'` so we have to special case
|
|
248
|
+
* `null` here.
|
|
249
|
+
*/
|
|
250
|
+
if (actual === null || (typeof actual !== 'object' && typeof actual !== 'function')) {
|
|
251
|
+
throw new AssertionError(`'${stringify(actual)}' is not a Primitive.`, failureMessage);
|
|
252
|
+
}
|
|
253
|
+
return actual;
|
|
254
|
+
},
|
|
152
255
|
/**
|
|
153
256
|
* Asserts that a value is _not_ a valid `PropertyKey`. `PropertyKey` is a built-in
|
|
154
257
|
* TypeScript type which refers to all possible key types for a JavaScript object. Returns
|
|
@@ -171,7 +274,14 @@ export const primitiveGuards = {
|
|
|
171
274
|
* @see
|
|
172
275
|
* - {@link assertWrap.isPropertyKey} : the opposite assertion.
|
|
173
276
|
*/
|
|
174
|
-
isNotPropertyKey
|
|
277
|
+
isNotPropertyKey(actual, failureMessage) {
|
|
278
|
+
if (typeof actual === 'string' ||
|
|
279
|
+
typeof actual === 'number' ||
|
|
280
|
+
typeof actual === 'symbol') {
|
|
281
|
+
throw new AssertionError(`'${stringify(actual)}' is a PropertyKey.`, failureMessage);
|
|
282
|
+
}
|
|
283
|
+
return actual;
|
|
284
|
+
},
|
|
175
285
|
/**
|
|
176
286
|
* Asserts that a value is a JavaScript
|
|
177
287
|
* [primitive](https://developer.mozilla.org/docs/Glossary/Primitive). Returns the value if
|
|
@@ -194,7 +304,16 @@ export const primitiveGuards = {
|
|
|
194
304
|
* @see
|
|
195
305
|
* - {@link assertWrap.isNotPrimitive} : the opposite assertion.
|
|
196
306
|
*/
|
|
197
|
-
isPrimitive
|
|
307
|
+
isPrimitive(actual, failureMessage) {
|
|
308
|
+
/**
|
|
309
|
+
* `null` is a primitive but `typeof null` gives `'object'` so we have to special case
|
|
310
|
+
* `null` here.
|
|
311
|
+
*/
|
|
312
|
+
if (actual !== null && (typeof actual === 'object' || typeof actual === 'function')) {
|
|
313
|
+
throw new AssertionError(`'${stringify(actual)}' is not a Primitive.`, failureMessage);
|
|
314
|
+
}
|
|
315
|
+
return actual;
|
|
316
|
+
},
|
|
198
317
|
/**
|
|
199
318
|
* Asserts that a value is _not_ a JavaScript
|
|
200
319
|
* [primitive](https://developer.mozilla.org/docs/Glossary/Primitive). Returns the value if
|
|
@@ -217,7 +336,14 @@ export const primitiveGuards = {
|
|
|
217
336
|
* @see
|
|
218
337
|
* - {@link assertWrap.isPrimitive} : the opposite assertion.
|
|
219
338
|
*/
|
|
220
|
-
isPropertyKey
|
|
339
|
+
isPropertyKey(actual, failureMessage) {
|
|
340
|
+
if (typeof actual !== 'string' &&
|
|
341
|
+
typeof actual !== 'number' &&
|
|
342
|
+
typeof actual !== 'symbol') {
|
|
343
|
+
throw new AssertionError(`'${stringify(actual)}' is not a PropertyKey.`, failureMessage);
|
|
344
|
+
}
|
|
345
|
+
return actual;
|
|
346
|
+
},
|
|
221
347
|
},
|
|
222
348
|
checkWrap: {
|
|
223
349
|
/**
|
|
@@ -232,16 +358,27 @@ export const primitiveGuards = {
|
|
|
232
358
|
* ```ts
|
|
233
359
|
* import {checkWrap} from '@augment-vir/assert';
|
|
234
360
|
*
|
|
235
|
-
* checkWrap.
|
|
236
|
-
* checkWrap.
|
|
237
|
-
* checkWrap.
|
|
361
|
+
* checkWrap.isNotPrimitive('key'); // returns `undefined`
|
|
362
|
+
* checkWrap.isNotPrimitive(true); // returns `undefined`
|
|
363
|
+
* checkWrap.isNotPrimitive({}); // returns `{}`
|
|
238
364
|
* ```
|
|
239
365
|
*
|
|
240
366
|
* @returns The value if the check passes, otherwise `undefined`.
|
|
241
367
|
* @see
|
|
242
|
-
* - {@link checkWrap.
|
|
368
|
+
* - {@link checkWrap.isPrimitive} : the opposite check.
|
|
243
369
|
*/
|
|
244
|
-
isNotPrimitive
|
|
370
|
+
isNotPrimitive(actual) {
|
|
371
|
+
/**
|
|
372
|
+
* `null` is a primitive but `typeof null` gives `'object'` so we have to special case
|
|
373
|
+
* `null` here.
|
|
374
|
+
*/
|
|
375
|
+
if (actual !== null && (typeof actual === 'object' || typeof actual === 'function')) {
|
|
376
|
+
return actual;
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
return undefined;
|
|
380
|
+
}
|
|
381
|
+
},
|
|
245
382
|
/**
|
|
246
383
|
* Checks that a value is _not_ a valid `PropertyKey`. `PropertyKey` is a built-in
|
|
247
384
|
* TypeScript type which refers to all possible key types for a JavaScript object. Returns
|
|
@@ -263,7 +400,16 @@ export const primitiveGuards = {
|
|
|
263
400
|
* @see
|
|
264
401
|
* - {@link checkWrap.isPropertyKey} : the opposite check.
|
|
265
402
|
*/
|
|
266
|
-
isNotPropertyKey
|
|
403
|
+
isNotPropertyKey(actual) {
|
|
404
|
+
if (typeof actual !== 'string' &&
|
|
405
|
+
typeof actual !== 'number' &&
|
|
406
|
+
typeof actual !== 'symbol') {
|
|
407
|
+
return actual;
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
return undefined;
|
|
411
|
+
}
|
|
412
|
+
},
|
|
267
413
|
/**
|
|
268
414
|
* Checks that a value is a JavaScript
|
|
269
415
|
* [primitive](https://developer.mozilla.org/docs/Glossary/Primitive). Returns the value if
|
|
@@ -285,7 +431,18 @@ export const primitiveGuards = {
|
|
|
285
431
|
* @see
|
|
286
432
|
* - {@link checkWrap.isNotPrimitive} : the opposite check.
|
|
287
433
|
*/
|
|
288
|
-
isPrimitive
|
|
434
|
+
isPrimitive(actual) {
|
|
435
|
+
/**
|
|
436
|
+
* `null` is a primitive but `typeof null` gives `'object'` so we have to special case
|
|
437
|
+
* `null` here.
|
|
438
|
+
*/
|
|
439
|
+
if (actual === null || (typeof actual !== 'object' && typeof actual !== 'function')) {
|
|
440
|
+
return actual;
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
return undefined;
|
|
444
|
+
}
|
|
445
|
+
},
|
|
289
446
|
/**
|
|
290
447
|
* Checks that a value is _not_ a JavaScript
|
|
291
448
|
* [primitive](https://developer.mozilla.org/docs/Glossary/Primitive). Returns the value if
|
|
@@ -307,7 +464,16 @@ export const primitiveGuards = {
|
|
|
307
464
|
* @see
|
|
308
465
|
* - {@link checkWrap.isPrimitive} : the opposite check.
|
|
309
466
|
*/
|
|
310
|
-
isPropertyKey
|
|
467
|
+
isPropertyKey(actual) {
|
|
468
|
+
if (typeof actual === 'string' ||
|
|
469
|
+
typeof actual === 'number' ||
|
|
470
|
+
typeof actual === 'symbol') {
|
|
471
|
+
return actual;
|
|
472
|
+
}
|
|
473
|
+
else {
|
|
474
|
+
return undefined;
|
|
475
|
+
}
|
|
476
|
+
},
|
|
311
477
|
},
|
|
312
478
|
waitUntil: {
|
|
313
479
|
/**
|
|
@@ -333,7 +499,7 @@ export const primitiveGuards = {
|
|
|
333
499
|
* @see
|
|
334
500
|
* - {@link waitUntil.isNotPropertyKey} : the opposite assertion.
|
|
335
501
|
*/
|
|
336
|
-
isNotPrimitive:
|
|
502
|
+
isNotPrimitive: createWaitUntil(assertions.isNotPrimitive),
|
|
337
503
|
/**
|
|
338
504
|
* Repeatedly calls a callback until its output is _not_ a valid `PropertyKey`.
|
|
339
505
|
* `PropertyKey` is a built-in TypeScript type which refers to all possible key types for a
|
|
@@ -357,7 +523,7 @@ export const primitiveGuards = {
|
|
|
357
523
|
* @see
|
|
358
524
|
* - {@link waitUntil.isPropertyKey} : the opposite assertion.
|
|
359
525
|
*/
|
|
360
|
-
isNotPropertyKey:
|
|
526
|
+
isNotPropertyKey: createWaitUntil(assertions.isNotPropertyKey),
|
|
361
527
|
/**
|
|
362
528
|
* Repeatedly calls a callback until its output is a JavaScript
|
|
363
529
|
* [primitive](https://developer.mozilla.org/docs/Glossary/Primitive). Once the callback
|
|
@@ -380,7 +546,7 @@ export const primitiveGuards = {
|
|
|
380
546
|
* @see
|
|
381
547
|
* - {@link waitUntil.isNotPrimitive} : the opposite assertion.
|
|
382
548
|
*/
|
|
383
|
-
isPrimitive:
|
|
549
|
+
isPrimitive: createWaitUntil(assertions.isPrimitive),
|
|
384
550
|
/**
|
|
385
551
|
* Repeatedly calls a callback until its output is _not_ a JavaScript
|
|
386
552
|
* [primitive](https://developer.mozilla.org/docs/Glossary/Primitive). Once the callback
|
|
@@ -403,6 +569,6 @@ export const primitiveGuards = {
|
|
|
403
569
|
* @see
|
|
404
570
|
* - {@link waitUntil.isPrimitive} : the opposite assertion.
|
|
405
571
|
*/
|
|
406
|
-
isPropertyKey:
|
|
572
|
+
isPropertyKey: createWaitUntil(assertions.isPropertyKey),
|
|
407
573
|
},
|
|
408
574
|
};
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import { autoGuardSymbol } from '../guard-types/guard-override.js';
|
|
2
1
|
import { type WaitUntilOptions } from '../guard-types/wait-until-function.js';
|
|
3
|
-
declare function isPromiseLike(actual: unknown, failureMessage?: string | undefined): asserts actual is PromiseLike<any>;
|
|
4
|
-
declare function isNotPromiseLike<const Actual>(actual: Actual, failureMessage?: string | undefined): asserts actual is Exclude<Actual, PromiseLike<any>>;
|
|
5
|
-
/**
|
|
6
|
-
* Checks if a value is an actual `Promise` object. In reality this is just a simple wrapper for
|
|
7
|
-
* `instanceof Promise`, but it makes checking a bit more ergonomic.
|
|
8
|
-
*/
|
|
9
|
-
declare function isPromise(actual: unknown, failureMessage?: string | undefined): asserts actual is Promise<any>;
|
|
10
|
-
declare function isNotPromise<const Actual>(actual: Actual, failureMessage?: string | undefined): asserts actual is Exclude<Actual, Promise<any>>;
|
|
11
2
|
export declare const promiseGuards: {
|
|
12
3
|
assert: {
|
|
13
4
|
/**
|
|
@@ -42,7 +33,7 @@ export declare const promiseGuards: {
|
|
|
42
33
|
* - {@link assert.isNotPromiseLike} : the opposite assertion.
|
|
43
34
|
* - {@link assert.isPromise} : the more precise assertion.
|
|
44
35
|
*/
|
|
45
|
-
isPromiseLike:
|
|
36
|
+
isPromiseLike(this: void, actual: unknown, failureMessage?: string | undefined): asserts actual is PromiseLike<any>;
|
|
46
37
|
/**
|
|
47
38
|
* Asserts that a value is _not_ a `PromiseLike`.
|
|
48
39
|
*
|
|
@@ -75,7 +66,7 @@ export declare const promiseGuards: {
|
|
|
75
66
|
* - {@link assert.isPromiseLike} : the opposite assertion.
|
|
76
67
|
* - {@link assert.isNotPromise} : the more precise assertion.
|
|
77
68
|
*/
|
|
78
|
-
isNotPromiseLike:
|
|
69
|
+
isNotPromiseLike<const Actual>(this: void, actual: Actual, failureMessage?: string | undefined): asserts actual is Exclude<Actual, PromiseLike<any>>;
|
|
79
70
|
/**
|
|
80
71
|
* Asserts that a value is a `Promise` instance.
|
|
81
72
|
*
|
|
@@ -104,7 +95,7 @@ export declare const promiseGuards: {
|
|
|
104
95
|
* - {@link assert.isNotPromise} : the opposite assertion.
|
|
105
96
|
* - {@link assert.isPromiseLike} : the more lenient assertion.
|
|
106
97
|
*/
|
|
107
|
-
isPromise:
|
|
98
|
+
isPromise(this: void, actual: unknown, failureMessage?: string | undefined): asserts actual is Promise<any>;
|
|
108
99
|
/**
|
|
109
100
|
* Asserts that a value is a _not_ `Promise` instance.
|
|
110
101
|
*
|
|
@@ -133,7 +124,7 @@ export declare const promiseGuards: {
|
|
|
133
124
|
* - {@link assert.isPromise} : the opposite assertion.
|
|
134
125
|
* - {@link assert.isNotPromiseLike} : the more lenient assertion.
|
|
135
126
|
*/
|
|
136
|
-
isNotPromise:
|
|
127
|
+
isNotPromise<const Actual>(this: void, actual: Actual, failureMessage?: string | undefined): asserts actual is Exclude<Actual, Promise<any>>;
|
|
137
128
|
};
|
|
138
129
|
check: {
|
|
139
130
|
/**
|
|
@@ -169,7 +160,7 @@ export declare const promiseGuards: {
|
|
|
169
160
|
* - {@link check.isNotPromiseLike} : the opposite check.
|
|
170
161
|
* - {@link check.isPromise} : the more precise check.
|
|
171
162
|
*/
|
|
172
|
-
isPromiseLike:
|
|
163
|
+
isPromiseLike<Actual>(this: void, actual: Actual): actual is Extract<Actual, PromiseLike<any>>;
|
|
173
164
|
/**
|
|
174
165
|
* Checks that a value is _not_ a `PromiseLike`.
|
|
175
166
|
*
|
|
@@ -203,7 +194,7 @@ export declare const promiseGuards: {
|
|
|
203
194
|
* - {@link check.isPromiseLike} : the opposite check.
|
|
204
195
|
* - {@link check.isNotPromise} : the more precise check.
|
|
205
196
|
*/
|
|
206
|
-
isNotPromiseLike
|
|
197
|
+
isNotPromiseLike<const Actual>(this: void, actual: Actual): actual is Exclude<Actual, PromiseLike<any>>;
|
|
207
198
|
/**
|
|
208
199
|
* Checks that a value is a `Promise` instance.
|
|
209
200
|
*
|
|
@@ -233,7 +224,7 @@ export declare const promiseGuards: {
|
|
|
233
224
|
* - {@link check.isNotPromise} : the opposite check.
|
|
234
225
|
* - {@link check.isPromiseLike} : the more lenient check.
|
|
235
226
|
*/
|
|
236
|
-
isPromise:
|
|
227
|
+
isPromise<Actual>(this: void, actual: Actual): actual is Extract<Actual, Promise<any>>;
|
|
237
228
|
/**
|
|
238
229
|
* Checks that a value is a _not_ `Promise` instance.
|
|
239
230
|
*
|
|
@@ -263,7 +254,7 @@ export declare const promiseGuards: {
|
|
|
263
254
|
* - {@link check.isPromise} : the opposite check.
|
|
264
255
|
* - {@link check.isNotPromiseLike} : the more lenient check.
|
|
265
256
|
*/
|
|
266
|
-
isNotPromise
|
|
257
|
+
isNotPromise<Actual>(this: void, actual: Actual): actual is Exclude<Actual, Promise<any>>;
|
|
267
258
|
};
|
|
268
259
|
assertWrap: {
|
|
269
260
|
/**
|
|
@@ -301,7 +292,7 @@ export declare const promiseGuards: {
|
|
|
301
292
|
* - {@link assertWrap.isNotPromiseLike} : the opposite assertion.
|
|
302
293
|
* - {@link assertWrap.isPromise} : the more precise assertion.
|
|
303
294
|
*/
|
|
304
|
-
isPromiseLike
|
|
295
|
+
isPromiseLike<Actual>(this: void, actual: Actual, failureMessage?: string | undefined): Extract<Actual, PromiseLike<any>>;
|
|
305
296
|
/**
|
|
306
297
|
* Asserts that a value is _not_ a `PromiseLike`. Returns the value if the assertion passes.
|
|
307
298
|
*
|
|
@@ -337,7 +328,7 @@ export declare const promiseGuards: {
|
|
|
337
328
|
* - {@link assertWrap.isPromiseLike} : the opposite assertion.
|
|
338
329
|
* - {@link assertWrap.isNotPromise} : the more precise assertion.
|
|
339
330
|
*/
|
|
340
|
-
isNotPromiseLike
|
|
331
|
+
isNotPromiseLike<Actual>(this: void, actual: Actual, failureMessage?: string | undefined): Exclude<Actual, PromiseLike<any>>;
|
|
341
332
|
/**
|
|
342
333
|
* Asserts that a value is a `Promise` instance. Returns the value if the assertion passes.
|
|
343
334
|
*
|
|
@@ -369,7 +360,7 @@ export declare const promiseGuards: {
|
|
|
369
360
|
* - {@link assertWrap.isNotPromise} : the opposite assertion.
|
|
370
361
|
* - {@link assertWrap.isPromiseLike} : the more lenient assertion.
|
|
371
362
|
*/
|
|
372
|
-
isPromise
|
|
363
|
+
isPromise<Actual>(this: void, actual: Actual, failureMessage?: string | undefined): Extract<Actual, Promise<any>>;
|
|
373
364
|
/**
|
|
374
365
|
* Asserts that a value is a _not_ `Promise` instance. Returns the value if the assertion
|
|
375
366
|
* passes.
|
|
@@ -402,7 +393,7 @@ export declare const promiseGuards: {
|
|
|
402
393
|
* - {@link assertWrap.isPromise} : the opposite assertion.
|
|
403
394
|
* - {@link assertWrap.isNotPromiseLike} : the more lenient assertion.
|
|
404
395
|
*/
|
|
405
|
-
isNotPromise
|
|
396
|
+
isNotPromise<Actual>(this: void, actual: Actual, failureMessage?: string | undefined): Exclude<Actual, Promise<any>>;
|
|
406
397
|
};
|
|
407
398
|
checkWrap: {
|
|
408
399
|
/**
|
|
@@ -439,7 +430,7 @@ export declare const promiseGuards: {
|
|
|
439
430
|
* - {@link checkWrap.isNotPromiseLike} : the opposite check.
|
|
440
431
|
* - {@link checkWrap.isPromise} : the more precise check.
|
|
441
432
|
*/
|
|
442
|
-
|
|
433
|
+
isPromiseLike<Actual>(this: void, actual: Actual): Extract<Actual, PromiseLike<any>> | undefined;
|
|
443
434
|
/**
|
|
444
435
|
* Checks that a value is _not_ a `PromiseLike`. Returns the value if the check passes,
|
|
445
436
|
* otherwise `undefined`.
|
|
@@ -474,7 +465,7 @@ export declare const promiseGuards: {
|
|
|
474
465
|
* - {@link checkWrap.isPromiseLike} : the opposite check.
|
|
475
466
|
* - {@link checkWrap.isNotPromise} : the more precise check.
|
|
476
467
|
*/
|
|
477
|
-
isNotPromiseLike
|
|
468
|
+
isNotPromiseLike<Actual>(this: void, actual: Actual): Exclude<Actual, PromiseLike<any>> | undefined;
|
|
478
469
|
/**
|
|
479
470
|
* Checks that a value is a `Promise` instance. Returns the value if the check passes,
|
|
480
471
|
* otherwise `undefined`.
|
|
@@ -505,7 +496,7 @@ export declare const promiseGuards: {
|
|
|
505
496
|
* - {@link checkWrap.isNotPromise} : the opposite check.
|
|
506
497
|
* - {@link checkWrap.isPromiseLike} : the more lenient check.
|
|
507
498
|
*/
|
|
508
|
-
isPromise:
|
|
499
|
+
isPromise<Actual>(this: void, actual: Actual): Extract<Actual, Promise<any>> | undefined;
|
|
509
500
|
/**
|
|
510
501
|
* Checks that a value is a _not_ `Promise` instance. Returns the value if the check passes,
|
|
511
502
|
* otherwise `undefined`.
|
|
@@ -536,7 +527,7 @@ export declare const promiseGuards: {
|
|
|
536
527
|
* - {@link checkWrap.isPromise} : the opposite check.
|
|
537
528
|
* - {@link checkWrap.isNotPromiseLike} : the more lenient check.
|
|
538
529
|
*/
|
|
539
|
-
|
|
530
|
+
isNotPromise<Actual>(this: void, actual: Actual): Exclude<Actual, Promise<any>> | undefined;
|
|
540
531
|
};
|
|
541
532
|
waitUntil: {
|
|
542
533
|
/**
|
|
@@ -575,7 +566,7 @@ export declare const promiseGuards: {
|
|
|
575
566
|
* - {@link waitUntil.isNotPromiseLike} : the opposite assertion.
|
|
576
567
|
* - {@link waitUntil.isPromise} : the more precise assertion.
|
|
577
568
|
*/
|
|
578
|
-
isPromiseLike: <const Actual>(callback: () => Actual, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Extract<Actual, PromiseLike<any>>>;
|
|
569
|
+
isPromiseLike: <const Actual>(this: void, callback: () => Actual, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Extract<Actual, PromiseLike<any>>>;
|
|
579
570
|
/**
|
|
580
571
|
* Repeatedly calls a callback until its output is _not_ a `PromiseLike`. Once the callback
|
|
581
572
|
* output passes, it is returned. If the attempts time out, an error is thrown.
|
|
@@ -612,7 +603,7 @@ export declare const promiseGuards: {
|
|
|
612
603
|
* - {@link waitUntil.isPromiseLike} : the opposite assertion.
|
|
613
604
|
* - {@link waitUntil.isNotPromise} : the more precise assertion.
|
|
614
605
|
*/
|
|
615
|
-
isNotPromiseLike: <const Actual>(callback: () => Actual, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, PromiseLike<any>>>;
|
|
606
|
+
isNotPromiseLike: <const Actual>(this: void, callback: () => Actual, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, PromiseLike<any>>>;
|
|
616
607
|
/**
|
|
617
608
|
* Repeatedly calls a callback until its output is a `Promise` instance. Once the callback
|
|
618
609
|
* output passes, it is returned. If the attempts time out, an error is thrown.
|
|
@@ -645,7 +636,7 @@ export declare const promiseGuards: {
|
|
|
645
636
|
* - {@link waitUntil.isNotPromise} : the opposite assertion.
|
|
646
637
|
* - {@link waitUntil.isPromiseLike} : the more lenient assertion.
|
|
647
638
|
*/
|
|
648
|
-
isPromise: <const Actual>(callback: () => Actual, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Extract<Actual, Promise<any>>>;
|
|
639
|
+
isPromise: <const Actual>(this: void, callback: () => Actual, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Extract<Actual, Promise<any>>>;
|
|
649
640
|
/**
|
|
650
641
|
* Repeatedly calls a callback until its output is a _not_ `Promise` instance. Once the
|
|
651
642
|
* callback output passes, it is returned. If the attempts time out, an error is thrown.
|
|
@@ -678,7 +669,6 @@ export declare const promiseGuards: {
|
|
|
678
669
|
* - {@link waitUntil.isPromise} : the opposite assertion.
|
|
679
670
|
* - {@link waitUntil.isNotPromiseLike} : the more lenient assertion.
|
|
680
671
|
*/
|
|
681
|
-
isNotPromise: <const Actual>(callback: () => Actual, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, Promise<any>>>;
|
|
672
|
+
isNotPromise: <const Actual>(this: void, callback: () => Actual, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, Promise<any>>>;
|
|
682
673
|
};
|
|
683
674
|
};
|
|
684
|
-
export {};
|