@augment-vir/assert 30.5.1 → 30.6.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.
@@ -1,6 +1,11 @@
1
+ import { type MinMax } from '@augment-vir/core';
1
2
  import { autoGuardSymbol } from '../guard-types/guard-override.js';
2
3
  declare function isAbove(actual: number, expected: number, failureMessage?: string | undefined): void;
3
4
  declare function isAtLeast(actual: number, expected: number, failureMessage?: string | undefined): void;
5
+ declare function isInBounds(actual: number, { max, min }: MinMax, failureMessage?: string | undefined): void;
6
+ declare function isOutBounds(actual: number, { min, max }: MinMax, failureMessage?: string | undefined): void;
7
+ declare function isInteger(actual: number, failureMessage?: string | undefined): void;
8
+ declare function isNotInteger(actual: number, failureMessage?: string | undefined): void;
4
9
  declare function isBelow(actual: number, expected: number, failureMessage?: string | undefined): void;
5
10
  declare function isAtMost(actual: number, expected: number, failureMessage?: string | undefined): void;
6
11
  declare function isNaNGuard(actual: number, failureMessage?: string | undefined): void;
@@ -10,6 +15,92 @@ declare function isApproximately(actual: number, expected: number, delta: number
10
15
  declare function isNotApproximately(actual: number, expected: number, delta: number, failureMessage?: string | undefined): void;
11
16
  export declare const numericGuards: {
12
17
  assert: {
18
+ /**
19
+ * Asserts that a number is inside the provided min and max bounds, inclusive.
20
+ *
21
+ * Performs no type guarding.
22
+ *
23
+ * @example
24
+ *
25
+ * ```ts
26
+ * import {assert} from '@augment-vir/assert';
27
+ *
28
+ * assert.isInBounds(5, {min: 1, max: 10}); // passes
29
+ * assert.isInBounds(10, {min: 1, max: 10}); // passes
30
+ * assert.isInBounds(11, {min: 1, max: 10}); // fails
31
+ * assert.isInBounds(0, {min: 1, max: 10}); // fails
32
+ * ```
33
+ *
34
+ * @throws {@link AssertionError} If the assertion fails.
35
+ * @see
36
+ * - {@link assert.isOutBounds} : the opposite assertion.
37
+ */
38
+ isInBounds: typeof isInBounds;
39
+ /**
40
+ * Asserts that a number is outside the provided min and max bounds, exclusive.
41
+ *
42
+ * Performs no type guarding.
43
+ *
44
+ * @example
45
+ *
46
+ * ```ts
47
+ * import {assert} from '@augment-vir/assert';
48
+ *
49
+ * assert.isOutBounds(5, {min: 1, max: 10}); // fails
50
+ * assert.isOutBounds(10, {min: 1, max: 10}); // fails
51
+ * assert.isOutBounds(11, {min: 1, max: 10}); // passes
52
+ * assert.isOutBounds(0, {min: 1, max: 10}); // passes
53
+ * ```
54
+ *
55
+ * @throws {@link AssertionError} If the assertion fails.
56
+ * @see
57
+ * - {@link assert.isInBounds} : the opposite assertion.
58
+ */
59
+ isOutBounds: typeof isOutBounds;
60
+ /**
61
+ * Asserts that a number is an integer. This has the same limitations as
62
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger.
63
+ *
64
+ * Performs no type guarding.
65
+ *
66
+ * @example
67
+ *
68
+ * ```ts
69
+ * import {assert} from '@augment-vir/assert';
70
+ *
71
+ * assert.isInteger(5); // passes
72
+ * assert.isInteger(5.0000000000000001); // passes
73
+ * assert.isInteger(5.1); // fails
74
+ * assert.isInteger(NaN); // fails
75
+ * ```
76
+ *
77
+ * @throws {@link AssertionError} If the assertion fails.
78
+ * @see
79
+ * - {@link assert.isNotInteger} : the opposite assertion.
80
+ */
81
+ isInteger: typeof isInteger;
82
+ /**
83
+ * Asserts that a number is not an integer. This has the same limitations, as
84
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger.
85
+ *
86
+ * Performs no type guarding.
87
+ *
88
+ * @example
89
+ *
90
+ * ```ts
91
+ * import {assert} from '@augment-vir/assert';
92
+ *
93
+ * assert.isNotInteger(5); // fails
94
+ * assert.isNotInteger(5.0000000000000001); // fails
95
+ * assert.isNotInteger(5.1); // passes
96
+ * assert.isNotInteger(NaN); // passes
97
+ * ```
98
+ *
99
+ * @throws {@link AssertionError} If the assertion fails.
100
+ * @see
101
+ * - {@link assert.isInteger} : the opposite assertion.
102
+ */
103
+ isNotInteger: typeof isNotInteger;
13
104
  /**
14
105
  * Asserts that a number is above the expectation (`actual > expected`).
15
106
  *
@@ -203,6 +294,88 @@ export declare const numericGuards: {
203
294
  isNotApproximately: typeof isNotApproximately;
204
295
  };
205
296
  check: {
297
+ /**
298
+ * Checks that a number is inside the provided min and max bounds, inclusive.
299
+ *
300
+ * Performs no type guarding.
301
+ *
302
+ * @example
303
+ *
304
+ * ```ts
305
+ * import {check} from '@augment-vir/assert';
306
+ *
307
+ * check.isInBounds(5, {min: 1, max: 10}); // passes
308
+ * check.isInBounds(10, {min: 1, max: 10}); // passes
309
+ * check.isInBounds(11, {min: 1, max: 10}); // fails
310
+ * check.isInBounds(0, {min: 1, max: 10}); // fails
311
+ * ```
312
+ *
313
+ * @see
314
+ * - {@link check.isOutBounds} : the opposite check.
315
+ */
316
+ isInBounds: typeof autoGuardSymbol;
317
+ /**
318
+ * Checks that a number is outside the provided min and max bounds, exclusive.
319
+ *
320
+ * Performs no type guarding.
321
+ *
322
+ * @example
323
+ *
324
+ * ```ts
325
+ * import {check} from '@augment-vir/assert';
326
+ *
327
+ * check.isOutBounds(5, {min: 1, max: 10}); // fails
328
+ * check.isOutBounds(10, {min: 1, max: 10}); // fails
329
+ * check.isOutBounds(11, {min: 1, max: 10}); // passes
330
+ * check.isOutBounds(0, {min: 1, max: 10}); // passes
331
+ * ```
332
+ *
333
+ * @see
334
+ * - {@link check.isInBounds} : the opposite check.
335
+ */
336
+ isOutBounds: typeof autoGuardSymbol;
337
+ /**
338
+ * Checks that a number is an integer. This has the same limitations as
339
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger.
340
+ *
341
+ * Performs no type guarding.
342
+ *
343
+ * @example
344
+ *
345
+ * ```ts
346
+ * import {check} from '@augment-vir/assert';
347
+ *
348
+ * check.isInteger(5); // passes
349
+ * check.isInteger(5.0000000000000001); // passes
350
+ * check.isInteger(5.1); // fails
351
+ * check.isInteger(NaN); // fails
352
+ * ```
353
+ *
354
+ * @see
355
+ * - {@link check.isNotInteger} : the opposite check.
356
+ */
357
+ isInteger: typeof autoGuardSymbol;
358
+ /**
359
+ * Checks that a number is not an integer. This has the same limitations, as
360
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger.
361
+ *
362
+ * Performs no type guarding.
363
+ *
364
+ * @example
365
+ *
366
+ * ```ts
367
+ * import {check} from '@augment-vir/assert';
368
+ *
369
+ * check.isNotInteger(5); // fails
370
+ * check.isNotInteger(5.0000000000000001); // fails
371
+ * check.isNotInteger(5.1); // passes
372
+ * check.isNotInteger(NaN); // passes
373
+ * ```
374
+ *
375
+ * @see
376
+ * - {@link check.isInteger} : the opposite check.
377
+ */
378
+ isNotInteger: typeof autoGuardSymbol;
206
379
  /**
207
380
  * Checks that a number is above the expectation (`actual > expected`).
208
381
  *
@@ -387,6 +560,96 @@ export declare const numericGuards: {
387
560
  isNotApproximately: typeof autoGuardSymbol;
388
561
  };
389
562
  assertWrap: {
563
+ /**
564
+ * Asserts that a number is inside the provided min and max bounds, inclusive. Returns the
565
+ * number if the assertion passes.
566
+ *
567
+ * Performs no type guarding.
568
+ *
569
+ * @example
570
+ *
571
+ * ```ts
572
+ * import {assertWrap} from '@augment-vir/assert';
573
+ *
574
+ * assertWrap.isInBounds(5, {min: 1, max: 10}); // returns `5`
575
+ * assertWrap.isInBounds(10, {min: 1, max: 10}); // returns `10`
576
+ * assertWrap.isInBounds(11, {min: 1, max: 10}); // fails
577
+ * assertWrap.isInBounds(0, {min: 1, max: 10}); // fails
578
+ * ```
579
+ *
580
+ * @throws {@link AssertionError} If the assertion fails.
581
+ * @see
582
+ * - {@link assertWrap.isOutBounds} : the opposite assertion.
583
+ */
584
+ isInBounds: typeof autoGuardSymbol;
585
+ /**
586
+ * Asserts that a number is outside the provided min and max bounds, exclusive. Returns the
587
+ * number if the assertion passes.
588
+ *
589
+ * Performs no type guarding.
590
+ *
591
+ * @example
592
+ *
593
+ * ```ts
594
+ * import {assertWrap} from '@augment-vir/assert';
595
+ *
596
+ * assertWrap.isOutBounds(5, {min: 1, max: 10}); // fails
597
+ * assertWrap.isOutBounds(10, {min: 1, max: 10}); // fails
598
+ * assertWrap.isOutBounds(11, {min: 1, max: 10}); // returns `11`
599
+ * assertWrap.isOutBounds(0, {min: 1, max: 10}); // returns `0`
600
+ * ```
601
+ *
602
+ * @throws {@link AssertionError} If the assertion fails.
603
+ * @see
604
+ * - {@link assertWrap.isInBounds} : the opposite assertion.
605
+ */
606
+ isOutBounds: typeof autoGuardSymbol;
607
+ /**
608
+ * Asserts that a number is an integer. Returns the number if the assertion passes. This has
609
+ * the same limitations as
610
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger.
611
+ *
612
+ * Performs no type guarding.
613
+ *
614
+ * @example
615
+ *
616
+ * ```ts
617
+ * import {assertWrap} from '@augment-vir/assert';
618
+ *
619
+ * assertWrap.isInteger(5); // returns `5`
620
+ * assertWrap.isInteger(5.0000000000000001); // returns `5`
621
+ * assertWrap.isInteger(5.1); // fails
622
+ * assertWrap.isInteger(NaN); // fails
623
+ * ```
624
+ *
625
+ * @throws {@link AssertionError} If the assertion fails.
626
+ * @see
627
+ * - {@link assertWrap.isNotInteger} : the opposite assertion.
628
+ */
629
+ isInteger: typeof autoGuardSymbol;
630
+ /**
631
+ * Asserts that a number is not an integer. Returns the number if the assertion passes. This
632
+ * has the same limitations, as
633
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger.
634
+ *
635
+ * Performs no type guarding.
636
+ *
637
+ * @example
638
+ *
639
+ * ```ts
640
+ * import {assertWrap} from '@augment-vir/assert';
641
+ *
642
+ * assertWrap.isNotInteger(5); // fails
643
+ * assertWrap.isNotInteger(5.0000000000000001); // fails
644
+ * assertWrap.isNotInteger(5.1); // returns `5.1`
645
+ * assertWrap.isNotInteger(NaN); // returns `NaN`
646
+ * ```
647
+ *
648
+ * @throws {@link AssertionError} If the assertion fails.
649
+ * @see
650
+ * - {@link assertWrap.isInteger} : the opposite assertion.
651
+ */
652
+ isNotInteger: typeof autoGuardSymbol;
390
653
  /**
391
654
  * Asserts that a number is above the expectation (`actual > expected`). Returns the number
392
655
  * if the assertion passes.
@@ -598,6 +861,92 @@ export declare const numericGuards: {
598
861
  isNotApproximately: typeof autoGuardSymbol;
599
862
  };
600
863
  checkWrap: {
864
+ /**
865
+ * Checks that a number is inside the provided min and max bounds, inclusive. Returns the
866
+ * number if the check passes, otherwise `undefined`.
867
+ *
868
+ * Performs no type guarding.
869
+ *
870
+ * @example
871
+ *
872
+ * ```ts
873
+ * import {checkWrap} from '@augment-vir/assert';
874
+ *
875
+ * checkWrap.isInBounds(5, {min: 1, max: 10}); // returns `5`
876
+ * checkWrap.isInBounds(10, {min: 1, max: 10}); // returns `10`
877
+ * checkWrap.isInBounds(11, {min: 1, max: 10}); // returns `undefined`
878
+ * checkWrap.isInBounds(0, {min: 1, max: 10}); // returns `undefined`
879
+ * ```
880
+ *
881
+ * @see
882
+ * - {@link checkWrap.isOutBounds} : the opposite check.
883
+ */
884
+ isInBounds: typeof autoGuardSymbol;
885
+ /**
886
+ * Checks that a number is outside the provided min and max bounds, exclusive. Returns the
887
+ * number if the check passes, otherwise `undefined`.
888
+ *
889
+ * Performs no type guarding.
890
+ *
891
+ * @example
892
+ *
893
+ * ```ts
894
+ * import {checkWrap} from '@augment-vir/assert';
895
+ *
896
+ * checkWrap.isOutBounds(5, {min: 1, max: 10}); // returns `undefined`
897
+ * checkWrap.isOutBounds(10, {min: 1, max: 10}); // returns `undefined`
898
+ * checkWrap.isOutBounds(11, {min: 1, max: 10}); // returns `11`
899
+ * checkWrap.isOutBounds(0, {min: 1, max: 10}); // returns `0`
900
+ * ```
901
+ *
902
+ * @see
903
+ * - {@link checkWrap.isInBounds} : the opposite check.
904
+ */
905
+ isOutBounds: typeof autoGuardSymbol;
906
+ /**
907
+ * Checks that a number is an integer. Returns the number if the check passes, otherwise
908
+ * `undefined`. This has the same limitations as
909
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger.
910
+ *
911
+ * Performs no type guarding.
912
+ *
913
+ * @example
914
+ *
915
+ * ```ts
916
+ * import {checkWrap} from '@augment-vir/assert';
917
+ *
918
+ * checkWrap.isInteger(5); // returns `5`
919
+ * checkWrap.isInteger(5.0000000000000001); // returns `5`
920
+ * checkWrap.isInteger(5.1); // returns `undefined`
921
+ * checkWrap.isInteger(NaN); // returns `undefined`
922
+ * ```
923
+ *
924
+ * @see
925
+ * - {@link checkWrap.isNotInteger} : the opposite check.
926
+ */
927
+ isInteger: typeof autoGuardSymbol;
928
+ /**
929
+ * Checks that a number is not an integer. Returns the number if the check passes, otherwise
930
+ * `undefined`. This has the same limitations, as
931
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger.
932
+ *
933
+ * Performs no type guarding.
934
+ *
935
+ * @example
936
+ *
937
+ * ```ts
938
+ * import {checkWrap} from '@augment-vir/assert';
939
+ *
940
+ * checkWrap.isNotInteger(5); // returns `undefined`
941
+ * checkWrap.isNotInteger(5.0000000000000001); // returns `undefined`
942
+ * checkWrap.isNotInteger(5.1); // returns `5.1`
943
+ * checkWrap.isNotInteger(NaN); // returns `NaN`
944
+ * ```
945
+ *
946
+ * @see
947
+ * - {@link checkWrap.isInteger} : the opposite check.
948
+ */
949
+ isNotInteger: typeof autoGuardSymbol;
601
950
  /**
602
951
  * Checks that a number is above the expectation (`actual > expected`). Returns the number
603
952
  * if the check passes, otherwise `undefined`.
@@ -800,6 +1149,98 @@ export declare const numericGuards: {
800
1149
  isNotApproximately: typeof autoGuardSymbol;
801
1150
  };
802
1151
  waitUntil: {
1152
+ /**
1153
+ * Repeatedly calls a callback until its output is a number is inside the provided min and
1154
+ * max bounds, inclusive. If the attempts time out, an error is thrown.
1155
+ *
1156
+ * Performs no type guarding.
1157
+ *
1158
+ * @example
1159
+ *
1160
+ * ```ts
1161
+ * import {waitUntil} from '@augment-vir/assert';
1162
+ *
1163
+ * waitUntil.isInBounds(5, {min: 1, max: 10}); // passes
1164
+ * waitUntil.isInBounds(10, {min: 1, max: 10}); // passes
1165
+ * waitUntil.isInBounds(11, {min: 1, max: 10}); // fails
1166
+ * waitUntil.isInBounds(0, {min: 1, max: 10}); // fails
1167
+ * ```
1168
+ *
1169
+ * @throws {@link AssertionError} If the assertion fails.
1170
+ * @see
1171
+ * - {@link waitUntil.isOutBounds} : the opposite assertion.
1172
+ */
1173
+ isInBounds: typeof autoGuardSymbol;
1174
+ /**
1175
+ * Repeatedly calls a callback until its output is outside the provided min and max bounds,
1176
+ * exclusive. If the attempts time out, an error is thrown.
1177
+ *
1178
+ * Performs no type guarding.
1179
+ *
1180
+ * @example
1181
+ *
1182
+ * ```ts
1183
+ * import {waitUntil} from '@augment-vir/assert';
1184
+ *
1185
+ * waitUntil.isOutBounds(5, {min: 1, max: 10}); // fails
1186
+ * waitUntil.isOutBounds(10, {min: 1, max: 10}); // fails
1187
+ * waitUntil.isOutBounds(11, {min: 1, max: 10}); // passes
1188
+ * waitUntil.isOutBounds(0, {min: 1, max: 10}); // passes
1189
+ * ```
1190
+ *
1191
+ * @throws {@link AssertionError} If the assertion fails.
1192
+ * @see
1193
+ * - {@link waitUntil.isInBounds} : the opposite assertion.
1194
+ */
1195
+ isOutBounds: typeof autoGuardSymbol;
1196
+ /**
1197
+ * Repeatedly calls a callback until its output is an integer. This has the same limitations
1198
+ * as
1199
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger.
1200
+ * If the attempts time out, an error is thrown.
1201
+ *
1202
+ * Performs no type guarding.
1203
+ *
1204
+ * @example
1205
+ *
1206
+ * ```ts
1207
+ * import {waitUntil} from '@augment-vir/assert';
1208
+ *
1209
+ * waitUntil.isInteger(5); // passes
1210
+ * waitUntil.isInteger(5.0000000000000001); // passes
1211
+ * waitUntil.isInteger(5.1); // fails
1212
+ * waitUntil.isInteger(NaN); // fails
1213
+ * ```
1214
+ *
1215
+ * @throws {@link AssertionError} If the assertion fails.
1216
+ * @see
1217
+ * - {@link waitUntil.isNotInteger} : the opposite assertion.
1218
+ */
1219
+ isInteger: typeof autoGuardSymbol;
1220
+ /**
1221
+ * Repeatedly calls a callback until its output is not an integer. This has the same
1222
+ * limitations, as
1223
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger.
1224
+ * If the attempts time out, an error is thrown.
1225
+ *
1226
+ * Performs no type guarding.
1227
+ *
1228
+ * @example
1229
+ *
1230
+ * ```ts
1231
+ * import {waitUntil} from '@augment-vir/assert';
1232
+ *
1233
+ * waitUntil.isNotInteger(5); // fails
1234
+ * waitUntil.isNotInteger(5.0000000000000001); // fails
1235
+ * waitUntil.isNotInteger(5.1); // passes
1236
+ * waitUntil.isNotInteger(NaN); // passes
1237
+ * ```
1238
+ *
1239
+ * @throws {@link AssertionError} If the assertion fails.
1240
+ * @see
1241
+ * - {@link waitUntil.isInteger} : the opposite assertion.
1242
+ */
1243
+ isNotInteger: typeof autoGuardSymbol;
803
1244
  /**
804
1245
  * Repeatedly calls a callback until its output is a number that is above the expectation
805
1246
  * (`actual > expected`). Once the callback output passes, it is returned. If the attempts
@@ -1,5 +1,7 @@
1
+ import { stringify } from '@augment-vir/core';
1
2
  import { AssertionError } from '../augments/assertion.error.js';
2
3
  import { autoGuardSymbol } from '../guard-types/guard-override.js';
4
+ import { isNumber } from './runtime-type.js';
3
5
  function isAbove(actual, expected, failureMessage) {
4
6
  if (actual <= expected) {
5
7
  throw new AssertionError(`${actual} is not above ${expected}`, failureMessage);
@@ -10,6 +12,27 @@ function isAtLeast(actual, expected, failureMessage) {
10
12
  throw new AssertionError(`${actual} is not at least ${expected}`, failureMessage);
11
13
  }
12
14
  }
15
+ function isInBounds(actual, { max, min }, failureMessage) {
16
+ if (actual < min || max < actual) {
17
+ throw new AssertionError(`${actual} is not within the bounds ${stringify({ min, max })}`, failureMessage);
18
+ }
19
+ }
20
+ function isOutBounds(actual, { min, max }, failureMessage) {
21
+ if (min <= actual && actual <= max) {
22
+ throw new AssertionError(`${actual} is not outside the bounds ${stringify({ min, max })}`, failureMessage);
23
+ }
24
+ }
25
+ function isInteger(actual, failureMessage) {
26
+ isNumber(actual);
27
+ if (!Number.isInteger(actual)) {
28
+ throw new AssertionError(`${actual} is not an integer.`, failureMessage);
29
+ }
30
+ }
31
+ function isNotInteger(actual, failureMessage) {
32
+ if (Number.isInteger(actual)) {
33
+ throw new AssertionError(`${actual} is an integer.`, failureMessage);
34
+ }
35
+ }
13
36
  function isBelow(actual, expected, failureMessage) {
14
37
  if (actual >= expected) {
15
38
  throw new AssertionError(`${actual} is not below ${expected}`, failureMessage);
@@ -46,6 +69,10 @@ function isNotApproximately(actual, expected, delta, failureMessage) {
46
69
  }
47
70
  }
48
71
  const assertions = {
72
+ isInBounds,
73
+ isOutBounds,
74
+ isInteger,
75
+ isNotInteger,
49
76
  isAbove,
50
77
  isAtLeast,
51
78
  isBelow,
@@ -59,6 +86,88 @@ const assertions = {
59
86
  export const numericGuards = {
60
87
  assert: assertions,
61
88
  check: {
89
+ /**
90
+ * Checks that a number is inside the provided min and max bounds, inclusive.
91
+ *
92
+ * Performs no type guarding.
93
+ *
94
+ * @example
95
+ *
96
+ * ```ts
97
+ * import {check} from '@augment-vir/assert';
98
+ *
99
+ * check.isInBounds(5, {min: 1, max: 10}); // passes
100
+ * check.isInBounds(10, {min: 1, max: 10}); // passes
101
+ * check.isInBounds(11, {min: 1, max: 10}); // fails
102
+ * check.isInBounds(0, {min: 1, max: 10}); // fails
103
+ * ```
104
+ *
105
+ * @see
106
+ * - {@link check.isOutBounds} : the opposite check.
107
+ */
108
+ isInBounds: autoGuardSymbol,
109
+ /**
110
+ * Checks that a number is outside the provided min and max bounds, exclusive.
111
+ *
112
+ * Performs no type guarding.
113
+ *
114
+ * @example
115
+ *
116
+ * ```ts
117
+ * import {check} from '@augment-vir/assert';
118
+ *
119
+ * check.isOutBounds(5, {min: 1, max: 10}); // fails
120
+ * check.isOutBounds(10, {min: 1, max: 10}); // fails
121
+ * check.isOutBounds(11, {min: 1, max: 10}); // passes
122
+ * check.isOutBounds(0, {min: 1, max: 10}); // passes
123
+ * ```
124
+ *
125
+ * @see
126
+ * - {@link check.isInBounds} : the opposite check.
127
+ */
128
+ isOutBounds: autoGuardSymbol,
129
+ /**
130
+ * Checks that a number is an integer. This has the same limitations as
131
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger.
132
+ *
133
+ * Performs no type guarding.
134
+ *
135
+ * @example
136
+ *
137
+ * ```ts
138
+ * import {check} from '@augment-vir/assert';
139
+ *
140
+ * check.isInteger(5); // passes
141
+ * check.isInteger(5.0000000000000001); // passes
142
+ * check.isInteger(5.1); // fails
143
+ * check.isInteger(NaN); // fails
144
+ * ```
145
+ *
146
+ * @see
147
+ * - {@link check.isNotInteger} : the opposite check.
148
+ */
149
+ isInteger: autoGuardSymbol,
150
+ /**
151
+ * Checks that a number is not an integer. This has the same limitations, as
152
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger.
153
+ *
154
+ * Performs no type guarding.
155
+ *
156
+ * @example
157
+ *
158
+ * ```ts
159
+ * import {check} from '@augment-vir/assert';
160
+ *
161
+ * check.isNotInteger(5); // fails
162
+ * check.isNotInteger(5.0000000000000001); // fails
163
+ * check.isNotInteger(5.1); // passes
164
+ * check.isNotInteger(NaN); // passes
165
+ * ```
166
+ *
167
+ * @see
168
+ * - {@link check.isInteger} : the opposite check.
169
+ */
170
+ isNotInteger: autoGuardSymbol,
62
171
  /**
63
172
  * Checks that a number is above the expectation (`actual > expected`).
64
173
  *
@@ -243,6 +352,96 @@ export const numericGuards = {
243
352
  isNotApproximately: autoGuardSymbol,
244
353
  },
245
354
  assertWrap: {
355
+ /**
356
+ * Asserts that a number is inside the provided min and max bounds, inclusive. Returns the
357
+ * number if the assertion passes.
358
+ *
359
+ * Performs no type guarding.
360
+ *
361
+ * @example
362
+ *
363
+ * ```ts
364
+ * import {assertWrap} from '@augment-vir/assert';
365
+ *
366
+ * assertWrap.isInBounds(5, {min: 1, max: 10}); // returns `5`
367
+ * assertWrap.isInBounds(10, {min: 1, max: 10}); // returns `10`
368
+ * assertWrap.isInBounds(11, {min: 1, max: 10}); // fails
369
+ * assertWrap.isInBounds(0, {min: 1, max: 10}); // fails
370
+ * ```
371
+ *
372
+ * @throws {@link AssertionError} If the assertion fails.
373
+ * @see
374
+ * - {@link assertWrap.isOutBounds} : the opposite assertion.
375
+ */
376
+ isInBounds: autoGuardSymbol,
377
+ /**
378
+ * Asserts that a number is outside the provided min and max bounds, exclusive. Returns the
379
+ * number if the assertion passes.
380
+ *
381
+ * Performs no type guarding.
382
+ *
383
+ * @example
384
+ *
385
+ * ```ts
386
+ * import {assertWrap} from '@augment-vir/assert';
387
+ *
388
+ * assertWrap.isOutBounds(5, {min: 1, max: 10}); // fails
389
+ * assertWrap.isOutBounds(10, {min: 1, max: 10}); // fails
390
+ * assertWrap.isOutBounds(11, {min: 1, max: 10}); // returns `11`
391
+ * assertWrap.isOutBounds(0, {min: 1, max: 10}); // returns `0`
392
+ * ```
393
+ *
394
+ * @throws {@link AssertionError} If the assertion fails.
395
+ * @see
396
+ * - {@link assertWrap.isInBounds} : the opposite assertion.
397
+ */
398
+ isOutBounds: autoGuardSymbol,
399
+ /**
400
+ * Asserts that a number is an integer. Returns the number if the assertion passes. This has
401
+ * the same limitations as
402
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger.
403
+ *
404
+ * Performs no type guarding.
405
+ *
406
+ * @example
407
+ *
408
+ * ```ts
409
+ * import {assertWrap} from '@augment-vir/assert';
410
+ *
411
+ * assertWrap.isInteger(5); // returns `5`
412
+ * assertWrap.isInteger(5.0000000000000001); // returns `5`
413
+ * assertWrap.isInteger(5.1); // fails
414
+ * assertWrap.isInteger(NaN); // fails
415
+ * ```
416
+ *
417
+ * @throws {@link AssertionError} If the assertion fails.
418
+ * @see
419
+ * - {@link assertWrap.isNotInteger} : the opposite assertion.
420
+ */
421
+ isInteger: autoGuardSymbol,
422
+ /**
423
+ * Asserts that a number is not an integer. Returns the number if the assertion passes. This
424
+ * has the same limitations, as
425
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger.
426
+ *
427
+ * Performs no type guarding.
428
+ *
429
+ * @example
430
+ *
431
+ * ```ts
432
+ * import {assertWrap} from '@augment-vir/assert';
433
+ *
434
+ * assertWrap.isNotInteger(5); // fails
435
+ * assertWrap.isNotInteger(5.0000000000000001); // fails
436
+ * assertWrap.isNotInteger(5.1); // returns `5.1`
437
+ * assertWrap.isNotInteger(NaN); // returns `NaN`
438
+ * ```
439
+ *
440
+ * @throws {@link AssertionError} If the assertion fails.
441
+ * @see
442
+ * - {@link assertWrap.isInteger} : the opposite assertion.
443
+ */
444
+ isNotInteger: autoGuardSymbol,
246
445
  /**
247
446
  * Asserts that a number is above the expectation (`actual > expected`). Returns the number
248
447
  * if the assertion passes.
@@ -454,6 +653,92 @@ export const numericGuards = {
454
653
  isNotApproximately: autoGuardSymbol,
455
654
  },
456
655
  checkWrap: {
656
+ /**
657
+ * Checks that a number is inside the provided min and max bounds, inclusive. Returns the
658
+ * number if the check passes, otherwise `undefined`.
659
+ *
660
+ * Performs no type guarding.
661
+ *
662
+ * @example
663
+ *
664
+ * ```ts
665
+ * import {checkWrap} from '@augment-vir/assert';
666
+ *
667
+ * checkWrap.isInBounds(5, {min: 1, max: 10}); // returns `5`
668
+ * checkWrap.isInBounds(10, {min: 1, max: 10}); // returns `10`
669
+ * checkWrap.isInBounds(11, {min: 1, max: 10}); // returns `undefined`
670
+ * checkWrap.isInBounds(0, {min: 1, max: 10}); // returns `undefined`
671
+ * ```
672
+ *
673
+ * @see
674
+ * - {@link checkWrap.isOutBounds} : the opposite check.
675
+ */
676
+ isInBounds: autoGuardSymbol,
677
+ /**
678
+ * Checks that a number is outside the provided min and max bounds, exclusive. Returns the
679
+ * number if the check passes, otherwise `undefined`.
680
+ *
681
+ * Performs no type guarding.
682
+ *
683
+ * @example
684
+ *
685
+ * ```ts
686
+ * import {checkWrap} from '@augment-vir/assert';
687
+ *
688
+ * checkWrap.isOutBounds(5, {min: 1, max: 10}); // returns `undefined`
689
+ * checkWrap.isOutBounds(10, {min: 1, max: 10}); // returns `undefined`
690
+ * checkWrap.isOutBounds(11, {min: 1, max: 10}); // returns `11`
691
+ * checkWrap.isOutBounds(0, {min: 1, max: 10}); // returns `0`
692
+ * ```
693
+ *
694
+ * @see
695
+ * - {@link checkWrap.isInBounds} : the opposite check.
696
+ */
697
+ isOutBounds: autoGuardSymbol,
698
+ /**
699
+ * Checks that a number is an integer. Returns the number if the check passes, otherwise
700
+ * `undefined`. This has the same limitations as
701
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger.
702
+ *
703
+ * Performs no type guarding.
704
+ *
705
+ * @example
706
+ *
707
+ * ```ts
708
+ * import {checkWrap} from '@augment-vir/assert';
709
+ *
710
+ * checkWrap.isInteger(5); // returns `5`
711
+ * checkWrap.isInteger(5.0000000000000001); // returns `5`
712
+ * checkWrap.isInteger(5.1); // returns `undefined`
713
+ * checkWrap.isInteger(NaN); // returns `undefined`
714
+ * ```
715
+ *
716
+ * @see
717
+ * - {@link checkWrap.isNotInteger} : the opposite check.
718
+ */
719
+ isInteger: autoGuardSymbol,
720
+ /**
721
+ * Checks that a number is not an integer. Returns the number if the check passes, otherwise
722
+ * `undefined`. This has the same limitations, as
723
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger.
724
+ *
725
+ * Performs no type guarding.
726
+ *
727
+ * @example
728
+ *
729
+ * ```ts
730
+ * import {checkWrap} from '@augment-vir/assert';
731
+ *
732
+ * checkWrap.isNotInteger(5); // returns `undefined`
733
+ * checkWrap.isNotInteger(5.0000000000000001); // returns `undefined`
734
+ * checkWrap.isNotInteger(5.1); // returns `5.1`
735
+ * checkWrap.isNotInteger(NaN); // returns `NaN`
736
+ * ```
737
+ *
738
+ * @see
739
+ * - {@link checkWrap.isInteger} : the opposite check.
740
+ */
741
+ isNotInteger: autoGuardSymbol,
457
742
  /**
458
743
  * Checks that a number is above the expectation (`actual > expected`). Returns the number
459
744
  * if the check passes, otherwise `undefined`.
@@ -656,6 +941,98 @@ export const numericGuards = {
656
941
  isNotApproximately: autoGuardSymbol,
657
942
  },
658
943
  waitUntil: {
944
+ /**
945
+ * Repeatedly calls a callback until its output is a number is inside the provided min and
946
+ * max bounds, inclusive. If the attempts time out, an error is thrown.
947
+ *
948
+ * Performs no type guarding.
949
+ *
950
+ * @example
951
+ *
952
+ * ```ts
953
+ * import {waitUntil} from '@augment-vir/assert';
954
+ *
955
+ * waitUntil.isInBounds(5, {min: 1, max: 10}); // passes
956
+ * waitUntil.isInBounds(10, {min: 1, max: 10}); // passes
957
+ * waitUntil.isInBounds(11, {min: 1, max: 10}); // fails
958
+ * waitUntil.isInBounds(0, {min: 1, max: 10}); // fails
959
+ * ```
960
+ *
961
+ * @throws {@link AssertionError} If the assertion fails.
962
+ * @see
963
+ * - {@link waitUntil.isOutBounds} : the opposite assertion.
964
+ */
965
+ isInBounds: autoGuardSymbol,
966
+ /**
967
+ * Repeatedly calls a callback until its output is outside the provided min and max bounds,
968
+ * exclusive. If the attempts time out, an error is thrown.
969
+ *
970
+ * Performs no type guarding.
971
+ *
972
+ * @example
973
+ *
974
+ * ```ts
975
+ * import {waitUntil} from '@augment-vir/assert';
976
+ *
977
+ * waitUntil.isOutBounds(5, {min: 1, max: 10}); // fails
978
+ * waitUntil.isOutBounds(10, {min: 1, max: 10}); // fails
979
+ * waitUntil.isOutBounds(11, {min: 1, max: 10}); // passes
980
+ * waitUntil.isOutBounds(0, {min: 1, max: 10}); // passes
981
+ * ```
982
+ *
983
+ * @throws {@link AssertionError} If the assertion fails.
984
+ * @see
985
+ * - {@link waitUntil.isInBounds} : the opposite assertion.
986
+ */
987
+ isOutBounds: autoGuardSymbol,
988
+ /**
989
+ * Repeatedly calls a callback until its output is an integer. This has the same limitations
990
+ * as
991
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger.
992
+ * If the attempts time out, an error is thrown.
993
+ *
994
+ * Performs no type guarding.
995
+ *
996
+ * @example
997
+ *
998
+ * ```ts
999
+ * import {waitUntil} from '@augment-vir/assert';
1000
+ *
1001
+ * waitUntil.isInteger(5); // passes
1002
+ * waitUntil.isInteger(5.0000000000000001); // passes
1003
+ * waitUntil.isInteger(5.1); // fails
1004
+ * waitUntil.isInteger(NaN); // fails
1005
+ * ```
1006
+ *
1007
+ * @throws {@link AssertionError} If the assertion fails.
1008
+ * @see
1009
+ * - {@link waitUntil.isNotInteger} : the opposite assertion.
1010
+ */
1011
+ isInteger: autoGuardSymbol,
1012
+ /**
1013
+ * Repeatedly calls a callback until its output is not an integer. This has the same
1014
+ * limitations, as
1015
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger.
1016
+ * If the attempts time out, an error is thrown.
1017
+ *
1018
+ * Performs no type guarding.
1019
+ *
1020
+ * @example
1021
+ *
1022
+ * ```ts
1023
+ * import {waitUntil} from '@augment-vir/assert';
1024
+ *
1025
+ * waitUntil.isNotInteger(5); // fails
1026
+ * waitUntil.isNotInteger(5.0000000000000001); // fails
1027
+ * waitUntil.isNotInteger(5.1); // passes
1028
+ * waitUntil.isNotInteger(NaN); // passes
1029
+ * ```
1030
+ *
1031
+ * @throws {@link AssertionError} If the assertion fails.
1032
+ * @see
1033
+ * - {@link waitUntil.isInteger} : the opposite assertion.
1034
+ */
1035
+ isNotInteger: autoGuardSymbol,
659
1036
  /**
660
1037
  * Repeatedly calls a callback until its output is a number that is above the expectation
661
1038
  * (`actual > expected`). Once the callback output passes, it is returned. If the attempts
@@ -16,7 +16,7 @@ declare function isArray<const Actual>(actual: Actual, failureMessage?: string |
16
16
  declare function isBigInt(actual: unknown, failureMessage?: string | undefined): asserts actual is bigint;
17
17
  declare function isBoolean(actual: unknown, failureMessage?: string | undefined): asserts actual is boolean;
18
18
  declare function isFunction<const Actual>(actual: Actual, failureMessage?: string | undefined): asserts actual is NarrowToActual<Actual, AnyFunction>;
19
- declare function isNumber(actual: unknown, failureMessage?: string | undefined): asserts actual is number;
19
+ export declare function isNumber(actual: unknown, failureMessage?: string | undefined): asserts actual is number;
20
20
  declare function isObject(actual: unknown, failureMessage?: string | undefined): asserts actual is UnknownObject;
21
21
  declare function isString(actual: unknown, failureMessage?: string | undefined): asserts actual is string;
22
22
  declare function isSymbol(actual: unknown, failureMessage?: string | undefined): asserts actual is symbol;
@@ -43,7 +43,7 @@ function isBoolean(actual, failureMessage) {
43
43
  function isFunction(actual, failureMessage) {
44
44
  assertRuntimeType(actual, 'function', failureMessage);
45
45
  }
46
- function isNumber(actual, failureMessage) {
46
+ export function isNumber(actual, failureMessage) {
47
47
  assertRuntimeType(actual, 'number', failureMessage);
48
48
  if (isNaN(actual)) {
49
49
  throw new AssertionError('Value is NaN.', failureMessage);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augment-vir/assert",
3
- "version": "30.5.1",
3
+ "version": "30.6.1",
4
4
  "description": "A collection of assertions for test and production code alike.",
5
5
  "keywords": [
6
6
  "augment",
@@ -41,7 +41,7 @@
41
41
  "test:update": "npm test"
42
42
  },
43
43
  "dependencies": {
44
- "@augment-vir/core": "^30.5.1",
44
+ "@augment-vir/core": "^30.6.1",
45
45
  "@date-vir/duration": "^6.0.1",
46
46
  "deep-eql": "^5.0.2",
47
47
  "expect-type": "^1.1.0",