@augment-vir/assert 30.0.0 → 30.0.2

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 +21 -8
@@ -19,26 +19,26 @@ import { throwGuards } from './throws.js';
19
19
  import { uuidGuards } from './uuid.js';
20
20
  import { valueGuards } from './values.js';
21
21
  export const extendableAssertions = {
22
- ...booleanGuards.assertions,
23
- ...boundaryGuards.assertions,
24
- ...entryEqualityGuards.assertions,
25
- ...enumGuards.assertions,
26
- ...instanceGuards.assertions,
27
- ...jsonEqualityGuards.assertions,
28
- ...keyGuards.assertions,
29
- ...lengthGuards.assertions,
30
- ...nullishGuards.assertions,
31
- ...numericGuards.assertions,
32
- ...primitiveGuards.assertions,
33
- ...promiseGuards.assertions,
34
- ...regexpGuards.assertions,
35
- ...runtimeTypeGuards.assertions,
36
- ...simpleEqualityGuards.assertions,
37
- ...throwGuards.assertions,
38
- ...uuidGuards.assertions,
39
- ...valueGuards.assertions,
40
- ...httpGuards.assertions,
41
- ...outputGuards.assertions,
22
+ ...booleanGuards.assert,
23
+ ...boundaryGuards.assert,
24
+ ...entryEqualityGuards.assert,
25
+ ...enumGuards.assert,
26
+ ...instanceGuards.assert,
27
+ ...jsonEqualityGuards.assert,
28
+ ...keyGuards.assert,
29
+ ...lengthGuards.assert,
30
+ ...nullishGuards.assert,
31
+ ...numericGuards.assert,
32
+ ...primitiveGuards.assert,
33
+ ...promiseGuards.assert,
34
+ ...regexpGuards.assert,
35
+ ...runtimeTypeGuards.assert,
36
+ ...simpleEqualityGuards.assert,
37
+ ...throwGuards.assert,
38
+ ...uuidGuards.assert,
39
+ ...valueGuards.assert,
40
+ ...httpGuards.assert,
41
+ ...outputGuards.assert,
42
42
  };
43
43
  /**
44
44
  * These overrides are required for more complex guards because TypeScript won't allow us to
@@ -66,43 +66,15 @@ export const guardOverrides = [
66
66
  httpGuards,
67
67
  outputGuards,
68
68
  ];
69
- export const checkOverrides = Object.assign({}, ...guardOverrides
70
- .map((entry) => {
71
- if ('checkOverrides' in entry) {
72
- return entry.checkOverrides;
73
- }
74
- else {
75
- return undefined;
76
- }
77
- })
78
- .filter((entry) => !!entry));
79
- export const assertWrapOverrides = Object.assign({}, ...guardOverrides
80
- .map((entry) => {
81
- if ('assertWrapOverrides' in entry) {
82
- return entry.assertWrapOverrides;
83
- }
84
- else {
85
- return undefined;
86
- }
87
- })
88
- .filter((entry) => !!entry));
89
- export const checkWrapOverrides = Object.assign({}, ...guardOverrides
90
- .map((entry) => {
91
- if ('checkWrapOverrides' in entry) {
92
- return entry.checkWrapOverrides;
93
- }
94
- else {
95
- return undefined;
96
- }
97
- })
98
- .filter((entry) => !!entry));
99
- export const waitUntilOverrides = Object.assign({}, ...guardOverrides
100
- .map((entry) => {
101
- if ('waitUntilOverrides' in entry) {
102
- return entry.waitUntilOverrides;
103
- }
104
- else {
105
- return undefined;
106
- }
107
- })
108
- .filter((entry) => !!entry));
69
+ export const checkOverrides = Object.assign({}, ...guardOverrides.map((entry) => {
70
+ return entry.check;
71
+ }));
72
+ export const assertWrapOverrides = Object.assign({}, ...guardOverrides.map((entry) => {
73
+ return entry.assertWrap;
74
+ }));
75
+ export const checkWrapOverrides = Object.assign({}, ...guardOverrides.map((entry) => {
76
+ return entry.checkWrap;
77
+ }));
78
+ export const waitUntilOverrides = Object.assign({}, ...guardOverrides.map((entry) => {
79
+ return entry.waitUntil;
80
+ }));
@@ -1,35 +1,242 @@
1
1
  import { HttpStatus, type HttpStatusByCategory, type HttpStatusCategory, type MaybePromise, type NarrowToExpected } from '@augment-vir/core';
2
+ import { autoGuardSymbol } from '../guard-types/guard-override.js';
2
3
  import type { WaitUntilOptions } from '../guard-types/wait-until-function.js';
3
4
  declare function isHttpStatus(actual: unknown, failureMessage?: string | undefined): asserts actual is HttpStatus;
4
5
  declare function isHttpStatusCategory<const Actual, const Category extends HttpStatusCategory>(actual: Actual, category: Category, failureMessage?: string | undefined): asserts actual is NarrowToExpected<Actual, HttpStatusByCategory<Category>>;
5
6
  export declare const httpGuards: {
6
- assertions: {
7
+ assert: {
7
8
  /**
8
- * Checks that a value is a standardized HTTP status code. See {@link HttpStatus} for the
9
- * statuses.
9
+ * Asserts that a value is an {@link HttpStatus}.
10
10
  *
11
11
  * Type guards the value.
12
+ *
13
+ * @example
14
+ *
15
+ * ```ts
16
+ * import {assert} from '@augment-vir/assert';
17
+ *
18
+ * assert.isHttpStatus(400); // passes
19
+ * assert.isHttpStatus(500); // passes
20
+ * assert.isHttpStatus(99); // fails
21
+ * ```
22
+ *
23
+ * @throws {@link AssertionError} If the value is not an {@link HttpStatus}.
24
+ * @see
25
+ * - {@link assert.isHttpStatusCategory} : the category assertion.
26
+ * - {@link HttpStatus} : all included statuses.
27
+ * - {@link HttpStatusCategory} : all status categories.
12
28
  */
13
29
  isHttpStatus: typeof isHttpStatus;
14
30
  /**
15
- * Checks that a value is a standardized HTTP status code within the given category of HTTP
16
- * status codes. See {@link HttpStatus} for the statuses and {@link HttpStatusCategory} for the
17
- * categories.
31
+ * Asserts that a value is an {@link HttpStatus} within a specific {@link HttpStatusCategory}.
18
32
  *
19
33
  * Type guards the value.
34
+ *
35
+ * @example
36
+ *
37
+ * ```ts
38
+ * import {assert} from '@augment-vir/assert';
39
+ *
40
+ * assert.isHttpStatusCategory(400, HttpStatusCategory.ClientError); // passes
41
+ * assert.isHttpStatusCategory(500, HttpStatusCategory.Success); // fails
42
+ * assert.isHttpStatusCategory(99, HttpStatusCategory.Information); // fails
43
+ * ```
44
+ *
45
+ * @throws {@link AssertionError} If the value is not an {@link HttpStatus} within the
46
+ * {@link HttpStatusCategory}.
47
+ * @see
48
+ * - {@link assert.isHttpStatus} : the status assertion.
49
+ * - {@link HttpStatus} : all included statuses.
50
+ * - {@link HttpStatusCategory} : all status categories.
20
51
  */
21
52
  isHttpStatusCategory: typeof isHttpStatusCategory;
22
53
  };
23
- checkOverrides: {
54
+ check: {
55
+ /**
56
+ * Checks that a value is an {@link HttpStatus}.
57
+ *
58
+ * Type guards the value.
59
+ *
60
+ * @example
61
+ *
62
+ * ```ts
63
+ * import {check} from '@augment-vir/assert';
64
+ *
65
+ * check.isHttpStatus(400); // returns `true`
66
+ * check.isHttpStatus(500); // returns `true`
67
+ * check.isHttpStatus(99); // returns `false`
68
+ * ```
69
+ *
70
+ * @see
71
+ * - {@link check.isHttpStatusCategory} : the category check.
72
+ * - {@link HttpStatus} : all included statuses.
73
+ * - {@link HttpStatusCategory} : all status categories.
74
+ */
75
+ isHttpStatus: typeof autoGuardSymbol;
76
+ /**
77
+ * Checks that a value is an {@link HttpStatus} within a specific {@link HttpStatusCategory}.
78
+ *
79
+ * Type guards the value.
80
+ *
81
+ * @example
82
+ *
83
+ * ```ts
84
+ * import {check} from '@augment-vir/assert';
85
+ *
86
+ * check.isHttpStatusCategory(400, HttpStatusCategory.ClientError); // returns `true`
87
+ * check.isHttpStatusCategory(500, HttpStatusCategory.Success); // returns `false`
88
+ * check.isHttpStatusCategory(99, HttpStatusCategory.Information); // returns `false`
89
+ * ```
90
+ *
91
+ * @see
92
+ * - {@link check.isHttpStatus} : the status check.
93
+ * - {@link HttpStatus} : all included statuses.
94
+ * - {@link HttpStatusCategory} : all status categories.
95
+ */
24
96
  isHttpStatusCategory: <const Actual, const Category extends HttpStatusCategory>(actual: Actual, category: Category, failureMessage?: string | undefined) => actual is NarrowToExpected<Actual, HttpStatusByCategory<Category>>;
25
97
  };
26
- assertWrapOverrides: {
98
+ assertWrap: {
99
+ /**
100
+ * Asserts that a value is an {@link HttpStatus}. Returns the value if the assertion passes.
101
+ *
102
+ * Type guards the value.
103
+ *
104
+ * @example
105
+ *
106
+ * ```ts
107
+ * import {assertWrap} from '@augment-vir/assert';
108
+ *
109
+ * assertWrap.isHttpStatus(400); // returns `400`
110
+ * assertWrap.isHttpStatus(500); // returns `500`
111
+ * assertWrap.isHttpStatus(99); // throws an error
112
+ * ```
113
+ *
114
+ * @throws {@link AssertionError} If the value is not an {@link HttpStatus}.
115
+ * @see
116
+ * - {@link assertWrap.isHttpStatusCategory} : the category assertion.
117
+ * - {@link HttpStatus} : all included statuses.
118
+ * - {@link HttpStatusCategory} : all status categories.
119
+ */
120
+ isHttpStatus: typeof autoGuardSymbol;
121
+ /**
122
+ * Checks that a value is an {@link HttpStatus} within a specific {@link HttpStatusCategory}.
123
+ * Returns the value if the assertion passes.
124
+ *
125
+ * Type guards the value.
126
+ *
127
+ * @example
128
+ *
129
+ * ```ts
130
+ * import {assertWrap} from '@augment-vir/assert';
131
+ *
132
+ * assertWrap.isHttpStatusCategory(400, HttpStatusCategory.ClientError); // returns `400`
133
+ * assertWrap.isHttpStatusCategory(500, HttpStatusCategory.Success); // throws an error
134
+ * assertWrap.isHttpStatusCategory(99, HttpStatusCategory.Information); // throws an error
135
+ * ```
136
+ *
137
+ * @see
138
+ * - {@link assertWrap.isHttpStatus} : the status assertion.
139
+ * - {@link HttpStatus} : all included statuses.
140
+ * - {@link HttpStatusCategory} : all status categories.
141
+ */
27
142
  isHttpStatusCategory: <const Actual, const Category extends HttpStatusCategory>(actual: Actual, category: Category, failureMessage?: string | undefined) => NarrowToExpected<Actual, HttpStatusByCategory<Category>>;
28
143
  };
29
- checkWrapOverrides: {
144
+ checkWrap: {
145
+ /**
146
+ * Checks that a value is an {@link HttpStatus}. Returns the value if the check passes,
147
+ * otherwise `undefined`.
148
+ *
149
+ * Type guards the value.
150
+ *
151
+ * @example
152
+ *
153
+ * ```ts
154
+ * import {checkWrap} from '@augment-vir/assert';
155
+ *
156
+ * checkWrap.isHttpStatus(400); // returns `400`
157
+ * checkWrap.isHttpStatus(500); // returns `500`
158
+ * checkWrap.isHttpStatus(99); // returns `undefined`
159
+ * ```
160
+ *
161
+ * @returns The value if the check passes, otherwise `undefined`.
162
+ * @see
163
+ * - {@link checkWrap.isHttpStatusCategory} : the category check.
164
+ * - {@link HttpStatus} : all included statuses.
165
+ * - {@link HttpStatusCategory} : all status categories.
166
+ */
167
+ isHttpStatus: typeof autoGuardSymbol;
168
+ /**
169
+ * Checks that a value is an {@link HttpStatus} within a specific {@link HttpStatusCategory}.
170
+ * Returns the value if the check passes, otherwise `undefined`.
171
+ *
172
+ * Type guards the value.
173
+ *
174
+ * @example
175
+ *
176
+ * ```ts
177
+ * import {checkWrap} from '@augment-vir/assert';
178
+ *
179
+ * checkWrap.isHttpStatusCategory(400, HttpStatusCategory.ClientError); // returns `400`
180
+ * checkWrap.isHttpStatusCategory(500, HttpStatusCategory.Success); // returns `undefined`
181
+ * checkWrap.isHttpStatusCategory(99, HttpStatusCategory.Information); // returns `undefined`
182
+ * ```
183
+ *
184
+ * @see
185
+ * - {@link checkWrap.isHttpStatus} : the status check.
186
+ * - {@link HttpStatus} : all included statuses.
187
+ * - {@link HttpStatusCategory} : all status categories.
188
+ */
30
189
  isHttpStatusCategory: <const Actual, const Category extends HttpStatusCategory>(actual: Actual, category: Category, failureMessage?: string | undefined) => NarrowToExpected<Actual, HttpStatusByCategory<Category>> | undefined;
31
190
  };
32
- waitUntilOverrides: {
191
+ waitUntil: {
192
+ /**
193
+ * Repeatedly calls a callback until its output is an {@link HttpStatus}. Once the callback
194
+ * output passes, it is returned. If the attempts time out, an error is thrown.
195
+ *
196
+ * Type guards the value.
197
+ *
198
+ * @example
199
+ *
200
+ * ```ts
201
+ * import {waitUntil} from '@augment-vir/assert';
202
+ *
203
+ * await waitUntil.isHttpStatus(() => 400); // returns `400`
204
+ * await waitUntil.isHttpStatus(() => 500); // returns `500`
205
+ * await waitUntil.isHttpStatus(() => 99); // throws an error
206
+ * ```
207
+ *
208
+ * @returns The callback output once it passes.
209
+ * @throws {@link AssertionError} On timeout.
210
+ * @see
211
+ * - {@link waitUntil.isHttpStatusCategory} : the category assertion.
212
+ * - {@link HttpStatus} : all included statuses.
213
+ * - {@link HttpStatusCategory} : all status categories.
214
+ */
215
+ isHttpStatus: typeof autoGuardSymbol;
216
+ /**
217
+ * Repeatedly calls a callback until its output is an {@link HttpStatus} within a specific
218
+ * {@link HttpStatusCategory}. Once the callback output passes, it is returned. If the
219
+ * attempts time out, an error is thrown.
220
+ *
221
+ * Type guards the value.
222
+ *
223
+ * @example
224
+ *
225
+ * ```ts
226
+ * import {waitUntil} from '@augment-vir/assert';
227
+ *
228
+ * await waitUntil.isHttpStatusCategory(HttpStatusCategory.ClientError, () => 400); // returns `400`
229
+ * await waitUntil.isHttpStatusCategory(HttpStatusCategory.Success, () => 500); // throws an error more
230
+ * await waitUntil.isHttpStatusCategory(HttpStatusCategory.Information, () => 99); // throws an error more
231
+ * ```
232
+ *
233
+ * @returns The callback output once it passes.
234
+ * @throws {@link AssertionError} On timeout.
235
+ * @see
236
+ * - {@link waitUntil.isHttpStatus} : the status assertion.
237
+ * - {@link HttpStatus} : all included statuses.
238
+ * - {@link HttpStatusCategory} : all status categories.
239
+ */
33
240
  isHttpStatusCategory: <const Actual, const Category extends HttpStatusCategory>(category: Category, callback: () => MaybePromise<Actual>, options?: WaitUntilOptions | undefined, failureMessage?: string | undefined) => Promise<NarrowToExpected<Actual, HttpStatusByCategory<Category>>>;
34
241
  };
35
242
  };
@@ -1,6 +1,6 @@
1
1
  import { HttpStatus, httpStatusByCategory, 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
  import { isEnumValue } from './enum.js';
5
5
  import { isIn } from './values.js';
6
6
  function isHttpStatus(actual, failureMessage) {
@@ -25,17 +25,193 @@ const assertions = {
25
25
  isHttpStatusCategory,
26
26
  };
27
27
  export const httpGuards = {
28
- assertions,
29
- checkOverrides: {
28
+ assert: assertions,
29
+ check: {
30
+ /**
31
+ * Checks that a value is an {@link HttpStatus}.
32
+ *
33
+ * Type guards the value.
34
+ *
35
+ * @example
36
+ *
37
+ * ```ts
38
+ * import {check} from '@augment-vir/assert';
39
+ *
40
+ * check.isHttpStatus(400); // returns `true`
41
+ * check.isHttpStatus(500); // returns `true`
42
+ * check.isHttpStatus(99); // returns `false`
43
+ * ```
44
+ *
45
+ * @see
46
+ * - {@link check.isHttpStatusCategory} : the category check.
47
+ * - {@link HttpStatus} : all included statuses.
48
+ * - {@link HttpStatusCategory} : all status categories.
49
+ */
50
+ isHttpStatus: autoGuardSymbol,
51
+ /**
52
+ * Checks that a value is an {@link HttpStatus} within a specific {@link HttpStatusCategory}.
53
+ *
54
+ * Type guards the value.
55
+ *
56
+ * @example
57
+ *
58
+ * ```ts
59
+ * import {check} from '@augment-vir/assert';
60
+ *
61
+ * check.isHttpStatusCategory(400, HttpStatusCategory.ClientError); // returns `true`
62
+ * check.isHttpStatusCategory(500, HttpStatusCategory.Success); // returns `false`
63
+ * check.isHttpStatusCategory(99, HttpStatusCategory.Information); // returns `false`
64
+ * ```
65
+ *
66
+ * @see
67
+ * - {@link check.isHttpStatus} : the status check.
68
+ * - {@link HttpStatus} : all included statuses.
69
+ * - {@link HttpStatusCategory} : all status categories.
70
+ */
30
71
  isHttpStatusCategory: autoGuard(),
31
72
  },
32
- assertWrapOverrides: {
73
+ assertWrap: {
74
+ /**
75
+ * Asserts that a value is an {@link HttpStatus}. Returns the value if the assertion passes.
76
+ *
77
+ * Type guards the value.
78
+ *
79
+ * @example
80
+ *
81
+ * ```ts
82
+ * import {assertWrap} from '@augment-vir/assert';
83
+ *
84
+ * assertWrap.isHttpStatus(400); // returns `400`
85
+ * assertWrap.isHttpStatus(500); // returns `500`
86
+ * assertWrap.isHttpStatus(99); // throws an error
87
+ * ```
88
+ *
89
+ * @throws {@link AssertionError} If the value is not an {@link HttpStatus}.
90
+ * @see
91
+ * - {@link assertWrap.isHttpStatusCategory} : the category assertion.
92
+ * - {@link HttpStatus} : all included statuses.
93
+ * - {@link HttpStatusCategory} : all status categories.
94
+ */
95
+ isHttpStatus: autoGuardSymbol,
96
+ /**
97
+ * Checks that a value is an {@link HttpStatus} within a specific {@link HttpStatusCategory}.
98
+ * Returns the value if the assertion passes.
99
+ *
100
+ * Type guards the value.
101
+ *
102
+ * @example
103
+ *
104
+ * ```ts
105
+ * import {assertWrap} from '@augment-vir/assert';
106
+ *
107
+ * assertWrap.isHttpStatusCategory(400, HttpStatusCategory.ClientError); // returns `400`
108
+ * assertWrap.isHttpStatusCategory(500, HttpStatusCategory.Success); // throws an error
109
+ * assertWrap.isHttpStatusCategory(99, HttpStatusCategory.Information); // throws an error
110
+ * ```
111
+ *
112
+ * @see
113
+ * - {@link assertWrap.isHttpStatus} : the status assertion.
114
+ * - {@link HttpStatus} : all included statuses.
115
+ * - {@link HttpStatusCategory} : all status categories.
116
+ */
33
117
  isHttpStatusCategory: autoGuard(),
34
118
  },
35
- checkWrapOverrides: {
119
+ checkWrap: {
120
+ /**
121
+ * Checks that a value is an {@link HttpStatus}. Returns the value if the check passes,
122
+ * otherwise `undefined`.
123
+ *
124
+ * Type guards the value.
125
+ *
126
+ * @example
127
+ *
128
+ * ```ts
129
+ * import {checkWrap} from '@augment-vir/assert';
130
+ *
131
+ * checkWrap.isHttpStatus(400); // returns `400`
132
+ * checkWrap.isHttpStatus(500); // returns `500`
133
+ * checkWrap.isHttpStatus(99); // returns `undefined`
134
+ * ```
135
+ *
136
+ * @returns The value if the check passes, otherwise `undefined`.
137
+ * @see
138
+ * - {@link checkWrap.isHttpStatusCategory} : the category check.
139
+ * - {@link HttpStatus} : all included statuses.
140
+ * - {@link HttpStatusCategory} : all status categories.
141
+ */
142
+ isHttpStatus: autoGuardSymbol,
143
+ /**
144
+ * Checks that a value is an {@link HttpStatus} within a specific {@link HttpStatusCategory}.
145
+ * Returns the value if the check passes, otherwise `undefined`.
146
+ *
147
+ * Type guards the value.
148
+ *
149
+ * @example
150
+ *
151
+ * ```ts
152
+ * import {checkWrap} from '@augment-vir/assert';
153
+ *
154
+ * checkWrap.isHttpStatusCategory(400, HttpStatusCategory.ClientError); // returns `400`
155
+ * checkWrap.isHttpStatusCategory(500, HttpStatusCategory.Success); // returns `undefined`
156
+ * checkWrap.isHttpStatusCategory(99, HttpStatusCategory.Information); // returns `undefined`
157
+ * ```
158
+ *
159
+ * @see
160
+ * - {@link checkWrap.isHttpStatus} : the status check.
161
+ * - {@link HttpStatus} : all included statuses.
162
+ * - {@link HttpStatusCategory} : all status categories.
163
+ */
36
164
  isHttpStatusCategory: autoGuard(),
37
165
  },
38
- waitUntilOverrides: {
166
+ waitUntil: {
167
+ /**
168
+ * Repeatedly calls a callback until its output is an {@link HttpStatus}. Once the callback
169
+ * output passes, it is returned. If the attempts time out, an error is thrown.
170
+ *
171
+ * Type guards the value.
172
+ *
173
+ * @example
174
+ *
175
+ * ```ts
176
+ * import {waitUntil} from '@augment-vir/assert';
177
+ *
178
+ * await waitUntil.isHttpStatus(() => 400); // returns `400`
179
+ * await waitUntil.isHttpStatus(() => 500); // returns `500`
180
+ * await waitUntil.isHttpStatus(() => 99); // throws an error
181
+ * ```
182
+ *
183
+ * @returns The callback output once it passes.
184
+ * @throws {@link AssertionError} On timeout.
185
+ * @see
186
+ * - {@link waitUntil.isHttpStatusCategory} : the category assertion.
187
+ * - {@link HttpStatus} : all included statuses.
188
+ * - {@link HttpStatusCategory} : all status categories.
189
+ */
190
+ isHttpStatus: autoGuardSymbol,
191
+ /**
192
+ * Repeatedly calls a callback until its output is an {@link HttpStatus} within a specific
193
+ * {@link HttpStatusCategory}. Once the callback output passes, it is returned. If the
194
+ * attempts time out, an error is thrown.
195
+ *
196
+ * Type guards the value.
197
+ *
198
+ * @example
199
+ *
200
+ * ```ts
201
+ * import {waitUntil} from '@augment-vir/assert';
202
+ *
203
+ * await waitUntil.isHttpStatusCategory(HttpStatusCategory.ClientError, () => 400); // returns `400`
204
+ * await waitUntil.isHttpStatusCategory(HttpStatusCategory.Success, () => 500); // throws an error more
205
+ * await waitUntil.isHttpStatusCategory(HttpStatusCategory.Information, () => 99); // throws an error more
206
+ * ```
207
+ *
208
+ * @returns The callback output once it passes.
209
+ * @throws {@link AssertionError} On timeout.
210
+ * @see
211
+ * - {@link waitUntil.isHttpStatus} : the status assertion.
212
+ * - {@link HttpStatus} : all included statuses.
213
+ * - {@link HttpStatusCategory} : all status categories.
214
+ */
39
215
  isHttpStatusCategory: autoGuard(),
40
216
  },
41
217
  };