ts-data-forge 6.7.0 → 6.9.0

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 (60) hide show
  1. package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
  2. package/dist/array/impl/array-utils-set-op.mjs +1 -3
  3. package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
  4. package/dist/array/impl/array-utils-transformation.d.mts +25 -0
  5. package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
  6. package/dist/array/impl/array-utils-transformation.mjs +36 -1
  7. package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
  8. package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
  9. package/dist/array/impl/array-utils-validation.mjs +2 -6
  10. package/dist/array/impl/array-utils-validation.mjs.map +1 -1
  11. package/dist/array/impl/index.mjs +1 -1
  12. package/dist/object/object.d.mts +56 -0
  13. package/dist/object/object.d.mts.map +1 -1
  14. package/dist/object/object.mjs +107 -1
  15. package/dist/object/object.mjs.map +1 -1
  16. package/dist/others/fast-deep-equal.d.mts.map +1 -1
  17. package/dist/others/fast-deep-equal.mjs +0 -1
  18. package/dist/others/fast-deep-equal.mjs.map +1 -1
  19. package/package.json +14 -14
  20. package/src/array/impl/array-utils-overload-type-error.test.mts +2 -4
  21. package/src/array/impl/array-utils-set-op.mts +0 -1
  22. package/src/array/impl/array-utils-transformation.mts +40 -0
  23. package/src/array/impl/array-utils-transformation.test.mts +54 -0
  24. package/src/array/impl/array-utils-validation.mts +2 -6
  25. package/src/functional/optional.test.mts +5 -7
  26. package/src/functional/result.test.mts +8 -10
  27. package/src/functional/ternary-result.test.mts +4 -4
  28. package/src/json/json.test.mts +5 -5
  29. package/src/number/branded-types/finite-number.test.mts +11 -15
  30. package/src/number/branded-types/int.test.mts +13 -13
  31. package/src/number/branded-types/int16.test.mts +15 -15
  32. package/src/number/branded-types/int32.test.mts +15 -15
  33. package/src/number/branded-types/non-negative-finite-number.test.mts +15 -19
  34. package/src/number/branded-types/non-negative-int16.test.mts +15 -15
  35. package/src/number/branded-types/non-negative-int32.test.mts +15 -15
  36. package/src/number/branded-types/non-zero-finite-number.test.mts +18 -18
  37. package/src/number/branded-types/non-zero-int.test.mts +14 -18
  38. package/src/number/branded-types/non-zero-int16.test.mts +15 -19
  39. package/src/number/branded-types/non-zero-int32.test.mts +15 -19
  40. package/src/number/branded-types/non-zero-safe-int.test.mts +18 -22
  41. package/src/number/branded-types/non-zero-uint16.test.mts +15 -15
  42. package/src/number/branded-types/non-zero-uint32.test.mts +15 -15
  43. package/src/number/branded-types/positive-finite-number.test.mts +18 -18
  44. package/src/number/branded-types/positive-int.test.mts +16 -22
  45. package/src/number/branded-types/positive-int16.test.mts +14 -14
  46. package/src/number/branded-types/positive-int32.test.mts +14 -14
  47. package/src/number/branded-types/positive-safe-int.test.mts +18 -20
  48. package/src/number/branded-types/positive-uint16.test.mts +15 -15
  49. package/src/number/branded-types/positive-uint32.test.mts +15 -15
  50. package/src/number/branded-types/safe-int.test.mts +17 -21
  51. package/src/number/branded-types/safe-uint.test.mts +16 -22
  52. package/src/number/branded-types/uint.test.mts +14 -14
  53. package/src/number/branded-types/uint16.test.mts +14 -14
  54. package/src/number/branded-types/uint32.test.mts +14 -14
  55. package/src/number/enum/int8.test.mts +1 -1
  56. package/src/number/enum/uint8.test.mts +1 -1
  57. package/src/object/object.mts +174 -1
  58. package/src/object/object.test.mts +172 -0
  59. package/src/others/fast-deep-equal.mts +0 -1
  60. package/src/others/unknown-to-string.test.mts +1 -1
@@ -5,47 +5,41 @@ import { asPositiveInt, isPositiveInt, PositiveInt } from './positive-int.mjs';
5
5
  describe('PositiveInt test', () => {
6
6
  describe(asPositiveInt, () => {
7
7
  test('accepts valid positive integers', () => {
8
- expect(() => asPositiveInt(1)).not.toThrowError();
8
+ expect(() => asPositiveInt(1)).not.toThrow();
9
9
 
10
- expect(() => asPositiveInt(2)).not.toThrowError();
10
+ expect(() => asPositiveInt(2)).not.toThrow();
11
11
 
12
- expect(() => asPositiveInt(42)).not.toThrowError();
12
+ expect(() => asPositiveInt(42)).not.toThrow();
13
13
 
14
- expect(() => asPositiveInt(100)).not.toThrowError();
14
+ expect(() => asPositiveInt(100)).not.toThrow();
15
15
 
16
- expect(() => asPositiveInt(Number.MAX_SAFE_INTEGER)).not.toThrowError();
16
+ expect(() => asPositiveInt(Number.MAX_SAFE_INTEGER)).not.toThrow();
17
17
  });
18
18
 
19
19
  test('rejects zero', () => {
20
- expect(() => asPositiveInt(0)).toThrowError(TypeError);
20
+ expect(() => asPositiveInt(0)).toThrow(TypeError);
21
21
 
22
- expect(() => asPositiveInt(-0)).toThrowError(TypeError);
22
+ expect(() => asPositiveInt(-0)).toThrow(TypeError);
23
23
  });
24
24
 
25
25
  test('rejects negative integers', () => {
26
- expect(() => asPositiveInt(-1)).toThrowError(TypeError);
26
+ expect(() => asPositiveInt(-1)).toThrow(TypeError);
27
27
 
28
- expect(() => asPositiveInt(-42)).toThrowError(TypeError);
28
+ expect(() => asPositiveInt(-42)).toThrow(TypeError);
29
29
 
30
- expect(() => asPositiveInt(Number.MIN_SAFE_INTEGER)).toThrowError(
31
- TypeError,
32
- );
30
+ expect(() => asPositiveInt(Number.MIN_SAFE_INTEGER)).toThrow(TypeError);
33
31
  });
34
32
 
35
33
  test('rejects non-integers', () => {
36
- expect(() => asPositiveInt(Number.NaN)).toThrowError(TypeError);
34
+ expect(() => asPositiveInt(Number.NaN)).toThrow(TypeError);
37
35
 
38
- expect(() => asPositiveInt(Number.POSITIVE_INFINITY)).toThrowError(
39
- TypeError,
40
- );
36
+ expect(() => asPositiveInt(Number.POSITIVE_INFINITY)).toThrow(TypeError);
41
37
 
42
- expect(() => asPositiveInt(Number.NEGATIVE_INFINITY)).toThrowError(
43
- TypeError,
44
- );
38
+ expect(() => asPositiveInt(Number.NEGATIVE_INFINITY)).toThrow(TypeError);
45
39
 
46
- expect(() => asPositiveInt(1.2)).toThrowError(TypeError);
40
+ expect(() => asPositiveInt(1.2)).toThrow(TypeError);
47
41
 
48
- expect(() => asPositiveInt(-3.4)).toThrowError(TypeError);
42
+ expect(() => asPositiveInt(-3.4)).toThrow(TypeError);
49
43
  });
50
44
 
51
45
  test('returns the same value for valid inputs', () => {
@@ -67,7 +61,7 @@ describe('PositiveInt test', () => {
67
61
  ] as const)(
68
62
  `asPositiveInt($name) should throw a TypeError`,
69
63
  ({ value }) => {
70
- expect(() => asPositiveInt(value)).toThrowError(
64
+ expect(() => asPositiveInt(value)).toThrow(
71
65
  new TypeError(`Expected a positive integer, got: ${value}`),
72
66
  );
73
67
  },
@@ -9,43 +9,43 @@ import {
9
9
  describe('PositiveInt16 test', () => {
10
10
  describe(asPositiveInt16, () => {
11
11
  test('accepts valid positive int16 values', () => {
12
- expect(() => asPositiveInt16(1)).not.toThrowError();
12
+ expect(() => asPositiveInt16(1)).not.toThrow();
13
13
 
14
- expect(() => asPositiveInt16(1000)).not.toThrowError();
14
+ expect(() => asPositiveInt16(1000)).not.toThrow();
15
15
 
16
- expect(() => asPositiveInt16(32_767)).not.toThrowError(); // 2^15 - 1
16
+ expect(() => asPositiveInt16(32_767)).not.toThrow(); // 2^15 - 1
17
17
  });
18
18
 
19
19
  test('rejects zero', () => {
20
- expect(() => asPositiveInt16(0)).toThrowError(TypeError);
20
+ expect(() => asPositiveInt16(0)).toThrow(TypeError);
21
21
  });
22
22
 
23
23
  test('rejects values outside int16 range', () => {
24
- expect(() => asPositiveInt16(32_768)).toThrowError(TypeError); // 2^15
24
+ expect(() => asPositiveInt16(32_768)).toThrow(TypeError); // 2^15
25
25
 
26
- expect(() => asPositiveInt16(65_536)).toThrowError(TypeError);
26
+ expect(() => asPositiveInt16(65_536)).toThrow(TypeError);
27
27
  });
28
28
 
29
29
  test('rejects negative integers', () => {
30
- expect(() => asPositiveInt16(-1)).toThrowError(TypeError);
30
+ expect(() => asPositiveInt16(-1)).toThrow(TypeError);
31
31
 
32
- expect(() => asPositiveInt16(-42)).toThrowError(TypeError);
32
+ expect(() => asPositiveInt16(-42)).toThrow(TypeError);
33
33
  });
34
34
 
35
35
  test('rejects non-integers', () => {
36
- expect(() => asPositiveInt16(Number.NaN)).toThrowError(TypeError);
36
+ expect(() => asPositiveInt16(Number.NaN)).toThrow(TypeError);
37
37
 
38
- expect(() => asPositiveInt16(Number.POSITIVE_INFINITY)).toThrowError(
38
+ expect(() => asPositiveInt16(Number.POSITIVE_INFINITY)).toThrow(
39
39
  TypeError,
40
40
  );
41
41
 
42
- expect(() => asPositiveInt16(Number.NEGATIVE_INFINITY)).toThrowError(
42
+ expect(() => asPositiveInt16(Number.NEGATIVE_INFINITY)).toThrow(
43
43
  TypeError,
44
44
  );
45
45
 
46
- expect(() => asPositiveInt16(1.2)).toThrowError(TypeError);
46
+ expect(() => asPositiveInt16(1.2)).toThrow(TypeError);
47
47
 
48
- expect(() => asPositiveInt16(-3.4)).toThrowError(TypeError);
48
+ expect(() => asPositiveInt16(-3.4)).toThrow(TypeError);
49
49
  });
50
50
 
51
51
  test('returns the same value for valid inputs', () => {
@@ -68,7 +68,7 @@ describe('PositiveInt16 test', () => {
68
68
  ] as const)(
69
69
  `asPositiveInt16($name) should throw a TypeError`,
70
70
  ({ value }) => {
71
- expect(() => asPositiveInt16(value)).toThrowError(
71
+ expect(() => asPositiveInt16(value)).toThrow(
72
72
  new TypeError(
73
73
  `Expected a positive integer in [1, 2^15), got: ${value}`,
74
74
  ),
@@ -9,43 +9,43 @@ import {
9
9
  describe('PositiveInt32 test', () => {
10
10
  describe(asPositiveInt32, () => {
11
11
  test('accepts valid positive int32 values', () => {
12
- expect(() => asPositiveInt32(1)).not.toThrowError();
12
+ expect(() => asPositiveInt32(1)).not.toThrow();
13
13
 
14
- expect(() => asPositiveInt32(1000)).not.toThrowError();
14
+ expect(() => asPositiveInt32(1000)).not.toThrow();
15
15
 
16
- expect(() => asPositiveInt32(2_147_483_647)).not.toThrowError(); // 2^31 - 1
16
+ expect(() => asPositiveInt32(2_147_483_647)).not.toThrow(); // 2^31 - 1
17
17
  });
18
18
 
19
19
  test('rejects zero', () => {
20
- expect(() => asPositiveInt32(0)).toThrowError(TypeError);
20
+ expect(() => asPositiveInt32(0)).toThrow(TypeError);
21
21
  });
22
22
 
23
23
  test('rejects values outside int32 range', () => {
24
- expect(() => asPositiveInt32(2_147_483_648)).toThrowError(TypeError); // 2^31
24
+ expect(() => asPositiveInt32(2_147_483_648)).toThrow(TypeError); // 2^31
25
25
 
26
- expect(() => asPositiveInt32(4_294_967_296)).toThrowError(TypeError);
26
+ expect(() => asPositiveInt32(4_294_967_296)).toThrow(TypeError);
27
27
  });
28
28
 
29
29
  test('rejects negative integers', () => {
30
- expect(() => asPositiveInt32(-1)).toThrowError(TypeError);
30
+ expect(() => asPositiveInt32(-1)).toThrow(TypeError);
31
31
 
32
- expect(() => asPositiveInt32(-42)).toThrowError(TypeError);
32
+ expect(() => asPositiveInt32(-42)).toThrow(TypeError);
33
33
  });
34
34
 
35
35
  test('rejects non-integers', () => {
36
- expect(() => asPositiveInt32(Number.NaN)).toThrowError(TypeError);
36
+ expect(() => asPositiveInt32(Number.NaN)).toThrow(TypeError);
37
37
 
38
- expect(() => asPositiveInt32(Number.POSITIVE_INFINITY)).toThrowError(
38
+ expect(() => asPositiveInt32(Number.POSITIVE_INFINITY)).toThrow(
39
39
  TypeError,
40
40
  );
41
41
 
42
- expect(() => asPositiveInt32(Number.NEGATIVE_INFINITY)).toThrowError(
42
+ expect(() => asPositiveInt32(Number.NEGATIVE_INFINITY)).toThrow(
43
43
  TypeError,
44
44
  );
45
45
 
46
- expect(() => asPositiveInt32(1.2)).toThrowError(TypeError);
46
+ expect(() => asPositiveInt32(1.2)).toThrow(TypeError);
47
47
 
48
- expect(() => asPositiveInt32(-3.4)).toThrowError(TypeError);
48
+ expect(() => asPositiveInt32(-3.4)).toThrow(TypeError);
49
49
  });
50
50
 
51
51
  test('returns the same value for valid inputs', () => {
@@ -68,7 +68,7 @@ describe('PositiveInt32 test', () => {
68
68
  ] as const)(
69
69
  `asPositiveInt32($name) should throw a TypeError`,
70
70
  ({ value }) => {
71
- expect(() => asPositiveInt32(value)).toThrowError(
71
+ expect(() => asPositiveInt32(value)).toThrow(
72
72
  new TypeError(
73
73
  `Expected a positive integer in [1, 2^31), got: ${value}`,
74
74
  ),
@@ -9,57 +9,55 @@ import {
9
9
  describe('PositiveSafeInt test', () => {
10
10
  describe(asPositiveSafeInt, () => {
11
11
  test('accepts valid positive safe integers', () => {
12
- expect(() => asPositiveSafeInt(1)).not.toThrowError();
12
+ expect(() => asPositiveSafeInt(1)).not.toThrow();
13
13
 
14
- expect(() => asPositiveSafeInt(2)).not.toThrowError();
14
+ expect(() => asPositiveSafeInt(2)).not.toThrow();
15
15
 
16
- expect(() => asPositiveSafeInt(42)).not.toThrowError();
16
+ expect(() => asPositiveSafeInt(42)).not.toThrow();
17
17
 
18
- expect(() => asPositiveSafeInt(100)).not.toThrowError();
18
+ expect(() => asPositiveSafeInt(100)).not.toThrow();
19
19
 
20
- expect(() =>
21
- asPositiveSafeInt(Number.MAX_SAFE_INTEGER),
22
- ).not.toThrowError();
20
+ expect(() => asPositiveSafeInt(Number.MAX_SAFE_INTEGER)).not.toThrow();
23
21
  });
24
22
 
25
23
  test('rejects zero', () => {
26
- expect(() => asPositiveSafeInt(0)).toThrowError(TypeError);
24
+ expect(() => asPositiveSafeInt(0)).toThrow(TypeError);
27
25
 
28
- expect(() => asPositiveSafeInt(-0)).toThrowError(TypeError);
26
+ expect(() => asPositiveSafeInt(-0)).toThrow(TypeError);
29
27
  });
30
28
 
31
29
  test('rejects negative integers', () => {
32
- expect(() => asPositiveSafeInt(-1)).toThrowError(TypeError);
30
+ expect(() => asPositiveSafeInt(-1)).toThrow(TypeError);
33
31
 
34
- expect(() => asPositiveSafeInt(-42)).toThrowError(TypeError);
32
+ expect(() => asPositiveSafeInt(-42)).toThrow(TypeError);
35
33
 
36
- expect(() => asPositiveSafeInt(Number.MIN_SAFE_INTEGER)).toThrowError(
34
+ expect(() => asPositiveSafeInt(Number.MIN_SAFE_INTEGER)).toThrow(
37
35
  TypeError,
38
36
  );
39
37
  });
40
38
 
41
39
  test('rejects values outside safe integer range', () => {
42
- expect(() => asPositiveSafeInt(Number.MAX_SAFE_INTEGER + 1)).toThrowError(
40
+ expect(() => asPositiveSafeInt(Number.MAX_SAFE_INTEGER + 1)).toThrow(
43
41
  TypeError,
44
42
  );
45
43
 
46
- expect(() => asPositiveSafeInt(Number.MAX_VALUE)).toThrowError(TypeError);
44
+ expect(() => asPositiveSafeInt(Number.MAX_VALUE)).toThrow(TypeError);
47
45
  });
48
46
 
49
47
  test('rejects non-integers', () => {
50
- expect(() => asPositiveSafeInt(Number.NaN)).toThrowError(TypeError);
48
+ expect(() => asPositiveSafeInt(Number.NaN)).toThrow(TypeError);
51
49
 
52
- expect(() => asPositiveSafeInt(Number.POSITIVE_INFINITY)).toThrowError(
50
+ expect(() => asPositiveSafeInt(Number.POSITIVE_INFINITY)).toThrow(
53
51
  TypeError,
54
52
  );
55
53
 
56
- expect(() => asPositiveSafeInt(Number.NEGATIVE_INFINITY)).toThrowError(
54
+ expect(() => asPositiveSafeInt(Number.NEGATIVE_INFINITY)).toThrow(
57
55
  TypeError,
58
56
  );
59
57
 
60
- expect(() => asPositiveSafeInt(1.2)).toThrowError(TypeError);
58
+ expect(() => asPositiveSafeInt(1.2)).toThrow(TypeError);
61
59
 
62
- expect(() => asPositiveSafeInt(-3.4)).toThrowError(TypeError);
60
+ expect(() => asPositiveSafeInt(-3.4)).toThrow(TypeError);
63
61
  });
64
62
 
65
63
  test('returns the same value for valid inputs', () => {
@@ -81,7 +79,7 @@ describe('PositiveSafeInt test', () => {
81
79
  ] as const)(
82
80
  `asPositiveSafeInt($name) should throw a TypeError`,
83
81
  ({ value }) => {
84
- expect(() => asPositiveSafeInt(value)).toThrowError(
82
+ expect(() => asPositiveSafeInt(value)).toThrow(
85
83
  new TypeError(`Expected a positive safe integer, got: ${value}`),
86
84
  );
87
85
  },
@@ -9,45 +9,45 @@ import {
9
9
  describe('PositiveUint16 test', () => {
10
10
  describe(asPositiveUint16, () => {
11
11
  test('accepts valid positive uint16 values', () => {
12
- expect(() => asPositiveUint16(1)).not.toThrowError();
12
+ expect(() => asPositiveUint16(1)).not.toThrow();
13
13
 
14
- expect(() => asPositiveUint16(1000)).not.toThrowError();
14
+ expect(() => asPositiveUint16(1000)).not.toThrow();
15
15
 
16
- expect(() => asPositiveUint16(65_535)).not.toThrowError(); // 2^16 - 1
16
+ expect(() => asPositiveUint16(65_535)).not.toThrow(); // 2^16 - 1
17
17
 
18
- expect(() => asPositiveUint16(32_768)).not.toThrowError(); // 2^15
18
+ expect(() => asPositiveUint16(32_768)).not.toThrow(); // 2^15
19
19
  });
20
20
 
21
21
  test('rejects zero', () => {
22
- expect(() => asPositiveUint16(0)).toThrowError(TypeError);
22
+ expect(() => asPositiveUint16(0)).toThrow(TypeError);
23
23
  });
24
24
 
25
25
  test('rejects values outside uint16 range', () => {
26
- expect(() => asPositiveUint16(65_536)).toThrowError(TypeError); // 2^16
26
+ expect(() => asPositiveUint16(65_536)).toThrow(TypeError); // 2^16
27
27
 
28
- expect(() => asPositiveUint16(100_000)).toThrowError(TypeError);
28
+ expect(() => asPositiveUint16(100_000)).toThrow(TypeError);
29
29
  });
30
30
 
31
31
  test('rejects negative integers', () => {
32
- expect(() => asPositiveUint16(-1)).toThrowError(TypeError);
32
+ expect(() => asPositiveUint16(-1)).toThrow(TypeError);
33
33
 
34
- expect(() => asPositiveUint16(-42)).toThrowError(TypeError);
34
+ expect(() => asPositiveUint16(-42)).toThrow(TypeError);
35
35
  });
36
36
 
37
37
  test('rejects non-integers', () => {
38
- expect(() => asPositiveUint16(Number.NaN)).toThrowError(TypeError);
38
+ expect(() => asPositiveUint16(Number.NaN)).toThrow(TypeError);
39
39
 
40
- expect(() => asPositiveUint16(Number.POSITIVE_INFINITY)).toThrowError(
40
+ expect(() => asPositiveUint16(Number.POSITIVE_INFINITY)).toThrow(
41
41
  TypeError,
42
42
  );
43
43
 
44
- expect(() => asPositiveUint16(Number.NEGATIVE_INFINITY)).toThrowError(
44
+ expect(() => asPositiveUint16(Number.NEGATIVE_INFINITY)).toThrow(
45
45
  TypeError,
46
46
  );
47
47
 
48
- expect(() => asPositiveUint16(1.2)).toThrowError(TypeError);
48
+ expect(() => asPositiveUint16(1.2)).toThrow(TypeError);
49
49
 
50
- expect(() => asPositiveUint16(-3.4)).toThrowError(TypeError);
50
+ expect(() => asPositiveUint16(-3.4)).toThrow(TypeError);
51
51
  });
52
52
 
53
53
  test('returns the same value for valid inputs', () => {
@@ -70,7 +70,7 @@ describe('PositiveUint16 test', () => {
70
70
  ] as const)(
71
71
  `asPositiveUint16($name) should throw a TypeError`,
72
72
  ({ value }) => {
73
- expect(() => asPositiveUint16(value)).toThrowError(
73
+ expect(() => asPositiveUint16(value)).toThrow(
74
74
  new TypeError(
75
75
  `Expected a positive integer in [1, 2^16), got: ${value}`,
76
76
  ),
@@ -9,45 +9,45 @@ import {
9
9
  describe('PositiveUint32 test', () => {
10
10
  describe(asPositiveUint32, () => {
11
11
  test('accepts valid positive uint32 values', () => {
12
- expect(() => asPositiveUint32(1)).not.toThrowError();
12
+ expect(() => asPositiveUint32(1)).not.toThrow();
13
13
 
14
- expect(() => asPositiveUint32(1000)).not.toThrowError();
14
+ expect(() => asPositiveUint32(1000)).not.toThrow();
15
15
 
16
- expect(() => asPositiveUint32(4_294_967_295)).not.toThrowError(); // 2^32 - 1
16
+ expect(() => asPositiveUint32(4_294_967_295)).not.toThrow(); // 2^32 - 1
17
17
 
18
- expect(() => asPositiveUint32(2_147_483_648)).not.toThrowError(); // 2^31
18
+ expect(() => asPositiveUint32(2_147_483_648)).not.toThrow(); // 2^31
19
19
  });
20
20
 
21
21
  test('rejects zero', () => {
22
- expect(() => asPositiveUint32(0)).toThrowError(TypeError);
22
+ expect(() => asPositiveUint32(0)).toThrow(TypeError);
23
23
  });
24
24
 
25
25
  test('rejects values outside uint32 range', () => {
26
- expect(() => asPositiveUint32(4_294_967_296)).toThrowError(TypeError); // 2^32
26
+ expect(() => asPositiveUint32(4_294_967_296)).toThrow(TypeError); // 2^32
27
27
 
28
- expect(() => asPositiveUint32(10_000_000_000)).toThrowError(TypeError);
28
+ expect(() => asPositiveUint32(10_000_000_000)).toThrow(TypeError);
29
29
  });
30
30
 
31
31
  test('rejects negative integers', () => {
32
- expect(() => asPositiveUint32(-1)).toThrowError(TypeError);
32
+ expect(() => asPositiveUint32(-1)).toThrow(TypeError);
33
33
 
34
- expect(() => asPositiveUint32(-42)).toThrowError(TypeError);
34
+ expect(() => asPositiveUint32(-42)).toThrow(TypeError);
35
35
  });
36
36
 
37
37
  test('rejects non-integers', () => {
38
- expect(() => asPositiveUint32(Number.NaN)).toThrowError(TypeError);
38
+ expect(() => asPositiveUint32(Number.NaN)).toThrow(TypeError);
39
39
 
40
- expect(() => asPositiveUint32(Number.POSITIVE_INFINITY)).toThrowError(
40
+ expect(() => asPositiveUint32(Number.POSITIVE_INFINITY)).toThrow(
41
41
  TypeError,
42
42
  );
43
43
 
44
- expect(() => asPositiveUint32(Number.NEGATIVE_INFINITY)).toThrowError(
44
+ expect(() => asPositiveUint32(Number.NEGATIVE_INFINITY)).toThrow(
45
45
  TypeError,
46
46
  );
47
47
 
48
- expect(() => asPositiveUint32(1.2)).toThrowError(TypeError);
48
+ expect(() => asPositiveUint32(1.2)).toThrow(TypeError);
49
49
 
50
- expect(() => asPositiveUint32(-3.4)).toThrowError(TypeError);
50
+ expect(() => asPositiveUint32(-3.4)).toThrow(TypeError);
51
51
  });
52
52
 
53
53
  test('returns the same value for valid inputs', () => {
@@ -70,7 +70,7 @@ describe('PositiveUint32 test', () => {
70
70
  ] as const)(
71
71
  `asPositiveUint32($name) should throw a TypeError`,
72
72
  ({ value }) => {
73
- expect(() => asPositiveUint32(value)).toThrowError(
73
+ expect(() => asPositiveUint32(value)).toThrow(
74
74
  new TypeError(
75
75
  `Expected a positive integer in [1, 2^32), got: ${value}`,
76
76
  ),
@@ -5,45 +5,41 @@ import { asSafeInt, SafeInt } from './safe-int.mjs';
5
5
  describe('SafeInt test', () => {
6
6
  describe(asSafeInt, () => {
7
7
  test('accepts valid safe integers', () => {
8
- expect(() => asSafeInt(0)).not.toThrowError();
8
+ expect(() => asSafeInt(0)).not.toThrow();
9
9
 
10
- expect(() => asSafeInt(1)).not.toThrowError();
10
+ expect(() => asSafeInt(1)).not.toThrow();
11
11
 
12
- expect(() => asSafeInt(-1)).not.toThrowError();
12
+ expect(() => asSafeInt(-1)).not.toThrow();
13
13
 
14
- expect(() => asSafeInt(42)).not.toThrowError();
14
+ expect(() => asSafeInt(42)).not.toThrow();
15
15
 
16
- expect(() => asSafeInt(-42)).not.toThrowError();
16
+ expect(() => asSafeInt(-42)).not.toThrow();
17
17
 
18
- expect(() => asSafeInt(Number.MAX_SAFE_INTEGER)).not.toThrowError();
18
+ expect(() => asSafeInt(Number.MAX_SAFE_INTEGER)).not.toThrow();
19
19
 
20
- expect(() => asSafeInt(Number.MIN_SAFE_INTEGER)).not.toThrowError();
20
+ expect(() => asSafeInt(Number.MIN_SAFE_INTEGER)).not.toThrow();
21
21
  });
22
22
 
23
23
  test('rejects values outside safe integer range', () => {
24
- expect(() => asSafeInt(Number.MAX_SAFE_INTEGER + 1)).toThrowError(
25
- TypeError,
26
- );
24
+ expect(() => asSafeInt(Number.MAX_SAFE_INTEGER + 1)).toThrow(TypeError);
27
25
 
28
- expect(() => asSafeInt(Number.MIN_SAFE_INTEGER - 1)).toThrowError(
29
- TypeError,
30
- );
26
+ expect(() => asSafeInt(Number.MIN_SAFE_INTEGER - 1)).toThrow(TypeError);
31
27
 
32
- expect(() => asSafeInt(Number.MAX_VALUE)).toThrowError(TypeError);
28
+ expect(() => asSafeInt(Number.MAX_VALUE)).toThrow(TypeError);
33
29
 
34
- expect(() => asSafeInt(-Number.MAX_VALUE)).toThrowError(TypeError);
30
+ expect(() => asSafeInt(-Number.MAX_VALUE)).toThrow(TypeError);
35
31
  });
36
32
 
37
33
  test('rejects non-integers', () => {
38
- expect(() => asSafeInt(Number.NaN)).toThrowError(TypeError);
34
+ expect(() => asSafeInt(Number.NaN)).toThrow(TypeError);
39
35
 
40
- expect(() => asSafeInt(Number.POSITIVE_INFINITY)).toThrowError(TypeError);
36
+ expect(() => asSafeInt(Number.POSITIVE_INFINITY)).toThrow(TypeError);
41
37
 
42
- expect(() => asSafeInt(Number.NEGATIVE_INFINITY)).toThrowError(TypeError);
38
+ expect(() => asSafeInt(Number.NEGATIVE_INFINITY)).toThrow(TypeError);
43
39
 
44
- expect(() => asSafeInt(1.2)).toThrowError(TypeError);
40
+ expect(() => asSafeInt(1.2)).toThrow(TypeError);
45
41
 
46
- expect(() => asSafeInt(-3.4)).toThrowError(TypeError);
42
+ expect(() => asSafeInt(-3.4)).toThrow(TypeError);
47
43
  });
48
44
 
49
45
  test('returns the same value for valid inputs', () => {
@@ -65,7 +61,7 @@ describe('SafeInt test', () => {
65
61
  { name: '1.2', value: 1.2 },
66
62
  { name: '-3.4', value: -3.4 },
67
63
  ] as const)(`asSafeInt($name) should throw a TypeError`, ({ value }) => {
68
- expect(() => asSafeInt(value)).toThrowError(
64
+ expect(() => asSafeInt(value)).toThrow(
69
65
  new TypeError(`Expected a safe integer, got: ${value}`),
70
66
  );
71
67
  });
@@ -5,47 +5,41 @@ import { asSafeUint, isSafeUint, SafeUint } from './safe-uint.mjs';
5
5
  describe('SafeUint test', () => {
6
6
  describe(asSafeUint, () => {
7
7
  test('accepts valid safe unsigned integers', () => {
8
- expect(() => asSafeUint(0)).not.toThrowError();
8
+ expect(() => asSafeUint(0)).not.toThrow();
9
9
 
10
- expect(() => asSafeUint(1)).not.toThrowError();
10
+ expect(() => asSafeUint(1)).not.toThrow();
11
11
 
12
- expect(() => asSafeUint(42)).not.toThrowError();
12
+ expect(() => asSafeUint(42)).not.toThrow();
13
13
 
14
- expect(() => asSafeUint(100)).not.toThrowError();
14
+ expect(() => asSafeUint(100)).not.toThrow();
15
15
 
16
- expect(() => asSafeUint(Number.MAX_SAFE_INTEGER)).not.toThrowError();
16
+ expect(() => asSafeUint(Number.MAX_SAFE_INTEGER)).not.toThrow();
17
17
  });
18
18
 
19
19
  test('rejects negative numbers', () => {
20
- expect(() => asSafeUint(-1)).toThrowError(TypeError);
20
+ expect(() => asSafeUint(-1)).toThrow(TypeError);
21
21
 
22
- expect(() => asSafeUint(-42)).toThrowError(TypeError);
22
+ expect(() => asSafeUint(-42)).toThrow(TypeError);
23
23
 
24
- expect(() => asSafeUint(Number.MIN_SAFE_INTEGER)).toThrowError(TypeError);
24
+ expect(() => asSafeUint(Number.MIN_SAFE_INTEGER)).toThrow(TypeError);
25
25
  });
26
26
 
27
27
  test('rejects values outside safe integer range', () => {
28
- expect(() => asSafeUint(Number.MAX_SAFE_INTEGER + 1)).toThrowError(
29
- TypeError,
30
- );
28
+ expect(() => asSafeUint(Number.MAX_SAFE_INTEGER + 1)).toThrow(TypeError);
31
29
 
32
- expect(() => asSafeUint(Number.MAX_VALUE)).toThrowError(TypeError);
30
+ expect(() => asSafeUint(Number.MAX_VALUE)).toThrow(TypeError);
33
31
  });
34
32
 
35
33
  test('rejects non-integers', () => {
36
- expect(() => asSafeUint(Number.NaN)).toThrowError(TypeError);
34
+ expect(() => asSafeUint(Number.NaN)).toThrow(TypeError);
37
35
 
38
- expect(() => asSafeUint(Number.POSITIVE_INFINITY)).toThrowError(
39
- TypeError,
40
- );
36
+ expect(() => asSafeUint(Number.POSITIVE_INFINITY)).toThrow(TypeError);
41
37
 
42
- expect(() => asSafeUint(Number.NEGATIVE_INFINITY)).toThrowError(
43
- TypeError,
44
- );
38
+ expect(() => asSafeUint(Number.NEGATIVE_INFINITY)).toThrow(TypeError);
45
39
 
46
- expect(() => asSafeUint(1.2)).toThrowError(TypeError);
40
+ expect(() => asSafeUint(1.2)).toThrow(TypeError);
47
41
 
48
- expect(() => asSafeUint(-3.4)).toThrowError(TypeError);
42
+ expect(() => asSafeUint(-3.4)).toThrow(TypeError);
49
43
  });
50
44
 
51
45
  test('returns the same value for valid inputs', () => {
@@ -66,7 +60,7 @@ describe('SafeUint test', () => {
66
60
  { name: '-3.4', value: -3.4 },
67
61
  { name: '-1', value: -1 },
68
62
  ] as const)(`asSafeUint($name) should throw a TypeError`, ({ value }) => {
69
- expect(() => asSafeUint(value)).toThrowError(
63
+ expect(() => asSafeUint(value)).toThrow(
70
64
  new TypeError(`Expected a non-negative safe integer, got: ${value}`),
71
65
  );
72
66
  });
@@ -5,35 +5,35 @@ import { asUint, isUint, Uint } from './uint.mjs';
5
5
  describe('Uint test', () => {
6
6
  describe(asUint, () => {
7
7
  test('accepts valid unsigned integers', () => {
8
- expect(() => asUint(0)).not.toThrowError();
8
+ expect(() => asUint(0)).not.toThrow();
9
9
 
10
- expect(() => asUint(1)).not.toThrowError();
10
+ expect(() => asUint(1)).not.toThrow();
11
11
 
12
- expect(() => asUint(42)).not.toThrowError();
12
+ expect(() => asUint(42)).not.toThrow();
13
13
 
14
- expect(() => asUint(100)).not.toThrowError();
14
+ expect(() => asUint(100)).not.toThrow();
15
15
 
16
- expect(() => asUint(Number.MAX_SAFE_INTEGER)).not.toThrowError();
16
+ expect(() => asUint(Number.MAX_SAFE_INTEGER)).not.toThrow();
17
17
  });
18
18
 
19
19
  test('rejects negative integers', () => {
20
- expect(() => asUint(-1)).toThrowError(TypeError);
20
+ expect(() => asUint(-1)).toThrow(TypeError);
21
21
 
22
- expect(() => asUint(-42)).toThrowError(TypeError);
22
+ expect(() => asUint(-42)).toThrow(TypeError);
23
23
 
24
- expect(() => asUint(Number.MIN_SAFE_INTEGER)).toThrowError(TypeError);
24
+ expect(() => asUint(Number.MIN_SAFE_INTEGER)).toThrow(TypeError);
25
25
  });
26
26
 
27
27
  test('rejects non-integers', () => {
28
- expect(() => asUint(Number.NaN)).toThrowError(TypeError);
28
+ expect(() => asUint(Number.NaN)).toThrow(TypeError);
29
29
 
30
- expect(() => asUint(Number.POSITIVE_INFINITY)).toThrowError(TypeError);
30
+ expect(() => asUint(Number.POSITIVE_INFINITY)).toThrow(TypeError);
31
31
 
32
- expect(() => asUint(Number.NEGATIVE_INFINITY)).toThrowError(TypeError);
32
+ expect(() => asUint(Number.NEGATIVE_INFINITY)).toThrow(TypeError);
33
33
 
34
- expect(() => asUint(1.2)).toThrowError(TypeError);
34
+ expect(() => asUint(1.2)).toThrow(TypeError);
35
35
 
36
- expect(() => asUint(-3.4)).toThrowError(TypeError);
36
+ expect(() => asUint(-3.4)).toThrow(TypeError);
37
37
  });
38
38
 
39
39
  test('returns the same value for valid inputs', () => {
@@ -52,7 +52,7 @@ describe('Uint test', () => {
52
52
  { name: '-3.4', value: -3.4 },
53
53
  { name: '-1', value: -1 },
54
54
  ] as const)(`asUint($name) should throw a TypeError`, ({ value }) => {
55
- expect(() => asUint(value)).toThrowError(
55
+ expect(() => asUint(value)).toThrow(
56
56
  new TypeError(`Expected a non-negative integer, got: ${value}`),
57
57
  );
58
58
  });