@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,5 +1,6 @@
|
|
|
1
1
|
import type { MaybePromise } from '@augment-vir/core';
|
|
2
2
|
import { Primitive } from 'type-fest';
|
|
3
|
+
import { autoGuardSymbol } from '../guard-types/guard-override.js';
|
|
3
4
|
import { WaitUntilOptions } from '../guard-types/wait-until-function.js';
|
|
4
5
|
export type { Primitive } from 'type-fest';
|
|
5
6
|
/** Asserts that the given value is a primitive. */
|
|
@@ -9,50 +10,452 @@ declare function isNotPrimitive<const Actual>(input: Actual, failureMessage?: st
|
|
|
9
10
|
declare function isPropertyKey(input: unknown, failureMessage?: string | undefined): asserts input is PropertyKey;
|
|
10
11
|
declare function isNotPropertyKey<const Actual>(input: Actual, failureMessage?: string | undefined): asserts input is Exclude<Actual, PropertyKey>;
|
|
11
12
|
export declare const primitiveGuards: {
|
|
12
|
-
|
|
13
|
+
assert: {
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
-
* refers to all possible key types for a JavaScript object.
|
|
15
|
+
* Asserts that a value is a valid `PropertyKey`. `PropertyKey` is a built-in TypeScript type
|
|
16
|
+
* which refers to all possible key types for a JavaScript object.
|
|
16
17
|
*
|
|
17
18
|
* Type guards the value.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* import {assert} from '@augment-vir/assert';
|
|
24
|
+
*
|
|
25
|
+
* assert.isPropertyKey('key'); // passes
|
|
26
|
+
* assert.isPropertyKey(true); // fails
|
|
27
|
+
* assert.isPropertyKey({}); // fails
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
31
|
+
* @see
|
|
32
|
+
* - {@link assert.isNotPropertyKey} : the opposite assertion.
|
|
18
33
|
*/
|
|
19
34
|
isPropertyKey: typeof isPropertyKey;
|
|
20
35
|
/**
|
|
21
|
-
*
|
|
22
|
-
* which refers to all possible key types for a JavaScript object.
|
|
36
|
+
* Asserts that a value is _not_ a valid `PropertyKey`. `PropertyKey` is a built-in TypeScript
|
|
37
|
+
* type which refers to all possible key types for a JavaScript object.
|
|
23
38
|
*
|
|
24
39
|
* Type guards the value.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
*
|
|
43
|
+
* ```ts
|
|
44
|
+
* import {assert} from '@augment-vir/assert';
|
|
45
|
+
*
|
|
46
|
+
* assert.isNotPropertyKey('key'); // fails
|
|
47
|
+
* assert.isNotPropertyKey(true); // passes
|
|
48
|
+
* assert.isNotPropertyKey({}); // passes
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
52
|
+
* @see
|
|
53
|
+
* - {@link assert.isPropertyKey} : the opposite assertion.
|
|
25
54
|
*/
|
|
26
55
|
isNotPropertyKey: typeof isNotPropertyKey;
|
|
27
56
|
/**
|
|
28
|
-
*
|
|
29
|
-
* [primitive](https://developer.mozilla.org/
|
|
57
|
+
* Asserts that a value is a JavaScript
|
|
58
|
+
* [primitive](https://developer.mozilla.org/docs/Glossary/Primitive).
|
|
30
59
|
*
|
|
31
60
|
* Type guards the value.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
*
|
|
64
|
+
* ```ts
|
|
65
|
+
* import {assert} from '@augment-vir/assert';
|
|
66
|
+
*
|
|
67
|
+
* assert.isPrimitive('key'); // passes
|
|
68
|
+
* assert.isPrimitive(true); // passes
|
|
69
|
+
* assert.isPrimitive({}); // fails
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
73
|
+
* @see
|
|
74
|
+
* - {@link assert.isNotPrimitive} : the opposite assertion.
|
|
32
75
|
*/
|
|
33
76
|
isPrimitive: typeof isPrimitive;
|
|
34
77
|
/**
|
|
35
|
-
*
|
|
36
|
-
* [primitive](https://developer.mozilla.org/
|
|
78
|
+
* Asserts that a value is _not_ a JavaScript
|
|
79
|
+
* [primitive](https://developer.mozilla.org/docs/Glossary/Primitive).
|
|
37
80
|
*
|
|
38
81
|
* Type guards the value.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
*
|
|
85
|
+
* ```ts
|
|
86
|
+
* import {assert} from '@augment-vir/assert';
|
|
87
|
+
*
|
|
88
|
+
* assert.isPrimitive('key'); // fails
|
|
89
|
+
* assert.isPrimitive(true); // fails
|
|
90
|
+
* assert.isPrimitive({}); // passes
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
94
|
+
* @see
|
|
95
|
+
* - {@link assert.isPrimitive} : the opposite assertion.
|
|
39
96
|
*/
|
|
40
97
|
isNotPrimitive: typeof isNotPrimitive;
|
|
41
98
|
};
|
|
42
|
-
|
|
99
|
+
check: {
|
|
100
|
+
/**
|
|
101
|
+
* Checks that a value is a valid `PropertyKey`. `PropertyKey` is a built-in TypeScript type
|
|
102
|
+
* which refers to all possible key types for a JavaScript object.
|
|
103
|
+
*
|
|
104
|
+
* Type guards the value.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
*
|
|
108
|
+
* ```ts
|
|
109
|
+
* import {check} from '@augment-vir/assert';
|
|
110
|
+
*
|
|
111
|
+
* check.isPropertyKey('key'); // returns `true`
|
|
112
|
+
* check.isPropertyKey(true); // returns `false`
|
|
113
|
+
* check.isPropertyKey({}); // returns `false`
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
* @see
|
|
117
|
+
* - {@link check.isNotPropertyKey} : the opposite check.
|
|
118
|
+
*/
|
|
43
119
|
isNotPrimitive: <const Actual>(input: Actual) => input is Exclude<Actual, Primitive>;
|
|
120
|
+
/**
|
|
121
|
+
* Checks that a value is _not_ a valid `PropertyKey`. `PropertyKey` is a built-in
|
|
122
|
+
* TypeScript type which refers to all possible key types for a JavaScript object.
|
|
123
|
+
*
|
|
124
|
+
* Type guards the value.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
*
|
|
128
|
+
* ```ts
|
|
129
|
+
* import {check} from '@augment-vir/assert';
|
|
130
|
+
*
|
|
131
|
+
* check.isNotPropertyKey('key'); // returns `false`
|
|
132
|
+
* check.isNotPropertyKey(true); // returns `true`
|
|
133
|
+
* check.isNotPropertyKey({}); // returns `true`
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* @see
|
|
137
|
+
* - {@link check.isPropertyKey} : the opposite check.
|
|
138
|
+
*/
|
|
44
139
|
isNotPropertyKey: <const Actual>(input: Actual) => input is Exclude<Actual, PropertyKey>;
|
|
140
|
+
/**
|
|
141
|
+
* Checks that a value is a JavaScript
|
|
142
|
+
* [primitive](https://developer.mozilla.org/docs/Glossary/Primitive).
|
|
143
|
+
*
|
|
144
|
+
* Type guards the value.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
*
|
|
148
|
+
* ```ts
|
|
149
|
+
* import {check} from '@augment-vir/assert';
|
|
150
|
+
*
|
|
151
|
+
* check.isPrimitive('key'); // returns `true`
|
|
152
|
+
* check.isPrimitive(true); // returns `true`
|
|
153
|
+
* check.isPrimitive({}); // returns `false`
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* @see
|
|
157
|
+
* - {@link check.isNotPrimitive} : the opposite check.
|
|
158
|
+
*/
|
|
159
|
+
isPrimitive: typeof autoGuardSymbol;
|
|
160
|
+
/**
|
|
161
|
+
* Checks that a value is _not_ a JavaScript
|
|
162
|
+
* [primitive](https://developer.mozilla.org/docs/Glossary/Primitive).
|
|
163
|
+
*
|
|
164
|
+
* Type guards the value.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
*
|
|
168
|
+
* ```ts
|
|
169
|
+
* import {check} from '@augment-vir/assert';
|
|
170
|
+
*
|
|
171
|
+
* check.isPrimitive('key'); // returns `false`
|
|
172
|
+
* check.isPrimitive(true); // returns `false`
|
|
173
|
+
* check.isPrimitive({}); // returns `true`
|
|
174
|
+
* ```
|
|
175
|
+
*
|
|
176
|
+
* @see
|
|
177
|
+
* - {@link check.isPrimitive} : the opposite check.
|
|
178
|
+
*/
|
|
179
|
+
isPropertyKey: typeof autoGuardSymbol;
|
|
45
180
|
};
|
|
46
|
-
|
|
181
|
+
assertWrap: {
|
|
182
|
+
/**
|
|
183
|
+
* Asserts that a value is a valid `PropertyKey`. `PropertyKey` is a built-in TypeScript
|
|
184
|
+
* type which refers to all possible key types for a JavaScript object. Returns the value if
|
|
185
|
+
* the assertion passes.
|
|
186
|
+
*
|
|
187
|
+
* Type guards the value.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
*
|
|
191
|
+
* ```ts
|
|
192
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
193
|
+
*
|
|
194
|
+
* assertWrap.isPropertyKey('key'); // returns `'key'`
|
|
195
|
+
* assertWrap.isPropertyKey(true); // throws an error
|
|
196
|
+
* assertWrap.isPropertyKey({}); // throws an error
|
|
197
|
+
* ```
|
|
198
|
+
*
|
|
199
|
+
* @returns The value if the assertion passes.
|
|
200
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
201
|
+
* @see
|
|
202
|
+
* - {@link assertWrap.isNotPropertyKey} : the opposite assertion.
|
|
203
|
+
*/
|
|
47
204
|
isNotPrimitive: <const Actual>(input: Actual, failureMessage?: string | undefined) => Exclude<Actual, Primitive>;
|
|
205
|
+
/**
|
|
206
|
+
* Asserts that a value is _not_ a valid `PropertyKey`. `PropertyKey` is a built-in
|
|
207
|
+
* TypeScript type which refers to all possible key types for a JavaScript object. Returns
|
|
208
|
+
* the value if the assertion passes.
|
|
209
|
+
*
|
|
210
|
+
* Type guards the value.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
*
|
|
214
|
+
* ```ts
|
|
215
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
216
|
+
*
|
|
217
|
+
* assertWrap.isNotPropertyKey('key'); // throws an error
|
|
218
|
+
* assertWrap.isNotPropertyKey(true); // returns `true`
|
|
219
|
+
* assertWrap.isNotPropertyKey({}); // returns `{}`
|
|
220
|
+
* ```
|
|
221
|
+
*
|
|
222
|
+
* @returns The value if the assertion passes.
|
|
223
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
224
|
+
* @see
|
|
225
|
+
* - {@link assertWrap.isPropertyKey} : the opposite assertion.
|
|
226
|
+
*/
|
|
48
227
|
isNotPropertyKey: <const Actual>(input: Actual, failureMessage?: string | undefined) => Exclude<Actual, PropertyKey>;
|
|
228
|
+
/**
|
|
229
|
+
* Asserts that a value is a JavaScript
|
|
230
|
+
* [primitive](https://developer.mozilla.org/docs/Glossary/Primitive). Returns the value if
|
|
231
|
+
* the assertion passes.
|
|
232
|
+
*
|
|
233
|
+
* Type guards the value.
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
*
|
|
237
|
+
* ```ts
|
|
238
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
239
|
+
*
|
|
240
|
+
* assertWrap.isPrimitive('key'); // returns `'key'`
|
|
241
|
+
* assertWrap.isPrimitive(true); // returns `true`
|
|
242
|
+
* assertWrap.isPrimitive({}); // throws an error
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
* @returns The value if the assertion passes.
|
|
246
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
247
|
+
* @see
|
|
248
|
+
* - {@link assertWrap.isNotPrimitive} : the opposite assertion.
|
|
249
|
+
*/
|
|
250
|
+
isPrimitive: typeof autoGuardSymbol;
|
|
251
|
+
/**
|
|
252
|
+
* Asserts that a value is _not_ a JavaScript
|
|
253
|
+
* [primitive](https://developer.mozilla.org/docs/Glossary/Primitive). Returns the value if
|
|
254
|
+
* the assertion passes.
|
|
255
|
+
*
|
|
256
|
+
* Type guards the value.
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
*
|
|
260
|
+
* ```ts
|
|
261
|
+
* import {assertWrap} from '@augment-vir/assert';
|
|
262
|
+
*
|
|
263
|
+
* assertWrap.isPrimitive('key'); // throws an error
|
|
264
|
+
* assertWrap.isPrimitive(true); // throws an error
|
|
265
|
+
* assertWrap.isPrimitive({}); // returns `{}`
|
|
266
|
+
* ```
|
|
267
|
+
*
|
|
268
|
+
* @returns The value if the assertion passes.
|
|
269
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
270
|
+
* @see
|
|
271
|
+
* - {@link assertWrap.isPrimitive} : the opposite assertion.
|
|
272
|
+
*/
|
|
273
|
+
isPropertyKey: typeof autoGuardSymbol;
|
|
49
274
|
};
|
|
50
|
-
|
|
275
|
+
checkWrap: {
|
|
276
|
+
/**
|
|
277
|
+
* Checks that a value is a valid `PropertyKey`. `PropertyKey` is a built-in TypeScript type
|
|
278
|
+
* which refers to all possible key types for a JavaScript object. Returns the value if the
|
|
279
|
+
* check passes, otherwise `undefined`.
|
|
280
|
+
*
|
|
281
|
+
* Type guards the value.
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
*
|
|
285
|
+
* ```ts
|
|
286
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
287
|
+
*
|
|
288
|
+
* checkWrap.isPropertyKey('key'); // returns `'key'`
|
|
289
|
+
* checkWrap.isPropertyKey(true); // returns `undefined`
|
|
290
|
+
* checkWrap.isPropertyKey({}); // returns `undefined`
|
|
291
|
+
* ```
|
|
292
|
+
*
|
|
293
|
+
* @returns The value if the check passes, otherwise `undefined`.
|
|
294
|
+
* @see
|
|
295
|
+
* - {@link checkWrap.isNotPropertyKey} : the opposite check.
|
|
296
|
+
*/
|
|
51
297
|
isNotPrimitive: <const Actual>(input: Actual) => Exclude<Actual, Primitive> | undefined;
|
|
298
|
+
/**
|
|
299
|
+
* Checks that a value is _not_ a valid `PropertyKey`. `PropertyKey` is a built-in
|
|
300
|
+
* TypeScript type which refers to all possible key types for a JavaScript object. Returns
|
|
301
|
+
* the value if the check passes, otherwise `undefined`.
|
|
302
|
+
*
|
|
303
|
+
* Type guards the value.
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
*
|
|
307
|
+
* ```ts
|
|
308
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
309
|
+
*
|
|
310
|
+
* checkWrap.isNotPropertyKey('key'); // returns `undefined`
|
|
311
|
+
* checkWrap.isNotPropertyKey(true); // returns `true`
|
|
312
|
+
* checkWrap.isNotPropertyKey({}); // returns `{}`
|
|
313
|
+
* ```
|
|
314
|
+
*
|
|
315
|
+
* @returns The value if the check passes, otherwise `undefined`.
|
|
316
|
+
* @see
|
|
317
|
+
* - {@link checkWrap.isPropertyKey} : the opposite check.
|
|
318
|
+
*/
|
|
52
319
|
isNotPropertyKey: <const Actual>(input: Actual) => Exclude<Actual, PropertyKey> | undefined;
|
|
320
|
+
/**
|
|
321
|
+
* Checks that a value is a JavaScript
|
|
322
|
+
* [primitive](https://developer.mozilla.org/docs/Glossary/Primitive). Returns the value if
|
|
323
|
+
* the check passes, otherwise `undefined`.
|
|
324
|
+
*
|
|
325
|
+
* Type guards the value.
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
*
|
|
329
|
+
* ```ts
|
|
330
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
331
|
+
*
|
|
332
|
+
* checkWrap.isPrimitive('key'); // returns `'key'`
|
|
333
|
+
* checkWrap.isPrimitive(true); // returns `true`
|
|
334
|
+
* checkWrap.isPrimitive({}); // returns `undefined`
|
|
335
|
+
* ```
|
|
336
|
+
*
|
|
337
|
+
* @returns The value if the check passes, otherwise `undefined`.
|
|
338
|
+
* @see
|
|
339
|
+
* - {@link checkWrap.isNotPrimitive} : the opposite check.
|
|
340
|
+
*/
|
|
341
|
+
isPrimitive: typeof autoGuardSymbol;
|
|
342
|
+
/**
|
|
343
|
+
* Checks that a value is _not_ a JavaScript
|
|
344
|
+
* [primitive](https://developer.mozilla.org/docs/Glossary/Primitive). Returns the value if
|
|
345
|
+
* the check passes, otherwise `undefined`.
|
|
346
|
+
*
|
|
347
|
+
* Type guards the value.
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
*
|
|
351
|
+
* ```ts
|
|
352
|
+
* import {checkWrap} from '@augment-vir/assert';
|
|
353
|
+
*
|
|
354
|
+
* checkWrap.isPrimitive('key'); // returns `undefined`
|
|
355
|
+
* checkWrap.isPrimitive(true); // returns `undefined`
|
|
356
|
+
* checkWrap.isPrimitive({}); // returns `{}`
|
|
357
|
+
* ```
|
|
358
|
+
*
|
|
359
|
+
* @returns The value if the check passes, otherwise `undefined`.
|
|
360
|
+
* @see
|
|
361
|
+
* - {@link checkWrap.isPrimitive} : the opposite check.
|
|
362
|
+
*/
|
|
363
|
+
isPropertyKey: typeof autoGuardSymbol;
|
|
53
364
|
};
|
|
54
|
-
|
|
365
|
+
waitUntil: {
|
|
366
|
+
/**
|
|
367
|
+
* Repeatedly calls a callback until its output is a valid `PropertyKey`. `PropertyKey` is a
|
|
368
|
+
* built-in TypeScript type which refers to all possible key types for a JavaScript object.
|
|
369
|
+
* Once the callback output passes, it is returned. If the attempts time out, an error is
|
|
370
|
+
* thrown.
|
|
371
|
+
*
|
|
372
|
+
* Type guards the value.
|
|
373
|
+
*
|
|
374
|
+
* @example
|
|
375
|
+
*
|
|
376
|
+
* ```ts
|
|
377
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
378
|
+
*
|
|
379
|
+
* await waitUntil.isPropertyKey('key'); // returns `'key'`
|
|
380
|
+
* await waitUntil.isPropertyKey(true); // throws an error
|
|
381
|
+
* await waitUntil.isPropertyKey({}); // throws an error
|
|
382
|
+
* ```
|
|
383
|
+
*
|
|
384
|
+
* @returns The callback output once it passes.
|
|
385
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
386
|
+
* @see
|
|
387
|
+
* - {@link waitUntil.isNotPropertyKey} : the opposite assertion.
|
|
388
|
+
*/
|
|
55
389
|
isNotPrimitive: <const Actual>(callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, Primitive>>;
|
|
390
|
+
/**
|
|
391
|
+
* Repeatedly calls a callback until its output is _not_ a valid `PropertyKey`.
|
|
392
|
+
* `PropertyKey` is a built-in TypeScript type which refers to all possible key types for a
|
|
393
|
+
* JavaScript object. Once the callback output passes, it is returned. If the attempts time
|
|
394
|
+
* out, an error is thrown.
|
|
395
|
+
*
|
|
396
|
+
* Type guards the value.
|
|
397
|
+
*
|
|
398
|
+
* @example
|
|
399
|
+
*
|
|
400
|
+
* ```ts
|
|
401
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
402
|
+
*
|
|
403
|
+
* await waitUntil.isNotPropertyKey('key'); // throws an error
|
|
404
|
+
* await waitUntil.isNotPropertyKey(true); // returns `true`
|
|
405
|
+
* await waitUntil.isNotPropertyKey({}); // returns `{}`
|
|
406
|
+
* ```
|
|
407
|
+
*
|
|
408
|
+
* @returns The callback output once it passes.
|
|
409
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
410
|
+
* @see
|
|
411
|
+
* - {@link waitUntil.isPropertyKey} : the opposite assertion.
|
|
412
|
+
*/
|
|
56
413
|
isNotPropertyKey: <const Actual>(callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<Exclude<Actual, PropertyKey>>;
|
|
414
|
+
/**
|
|
415
|
+
* Repeatedly calls a callback until its output is a JavaScript
|
|
416
|
+
* [primitive](https://developer.mozilla.org/docs/Glossary/Primitive). Once the callback
|
|
417
|
+
* output passes, it is returned. If the attempts time out, an error is thrown.
|
|
418
|
+
*
|
|
419
|
+
* Type guards the value.
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
*
|
|
423
|
+
* ```ts
|
|
424
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
425
|
+
*
|
|
426
|
+
* await waitUntil.isPrimitive('key'); // returns `'key'`
|
|
427
|
+
* await waitUntil.isPrimitive(true); // returns `true`
|
|
428
|
+
* await waitUntil.isPrimitive({}); // throws an error
|
|
429
|
+
* ```
|
|
430
|
+
*
|
|
431
|
+
* @returns The callback output once it passes.
|
|
432
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
433
|
+
* @see
|
|
434
|
+
* - {@link waitUntil.isNotPrimitive} : the opposite assertion.
|
|
435
|
+
*/
|
|
436
|
+
isPrimitive: typeof autoGuardSymbol;
|
|
437
|
+
/**
|
|
438
|
+
* Repeatedly calls a callback until its output is _not_ a JavaScript
|
|
439
|
+
* [primitive](https://developer.mozilla.org/docs/Glossary/Primitive). Once the callback
|
|
440
|
+
* output passes, it is returned. If the attempts time out, an error is thrown.
|
|
441
|
+
*
|
|
442
|
+
* Type guards the value.
|
|
443
|
+
*
|
|
444
|
+
* @example
|
|
445
|
+
*
|
|
446
|
+
* ```ts
|
|
447
|
+
* import {waitUntil} from '@augment-vir/assert';
|
|
448
|
+
*
|
|
449
|
+
* await waitUntil.isPrimitive('key'); // throws an error
|
|
450
|
+
* await waitUntil.isPrimitive(true); // throws an error
|
|
451
|
+
* await waitUntil.isPrimitive({}); // returns `{}`
|
|
452
|
+
* ```
|
|
453
|
+
*
|
|
454
|
+
* @returns The callback output once it passes.
|
|
455
|
+
* @throws {@link AssertionError} If the assertion fails.
|
|
456
|
+
* @see
|
|
457
|
+
* - {@link waitUntil.isPrimitive} : the opposite assertion.
|
|
458
|
+
*/
|
|
459
|
+
isPropertyKey: typeof autoGuardSymbol;
|
|
57
460
|
};
|
|
58
461
|
};
|