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