ts-data-forge 6.4.0 → 6.6.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 (181) hide show
  1. package/README.md +5 -3
  2. package/dist/array/impl/array-utils-element-access.d.mts +5 -5
  3. package/dist/array/impl/array-utils-element-access.mjs +4 -4
  4. package/dist/array/impl/array-utils-iterators.d.mts +1 -1
  5. package/dist/array/impl/array-utils-iterators.mjs +1 -1
  6. package/dist/array/impl/array-utils-modification.d.mts +4 -4
  7. package/dist/array/impl/array-utils-reducing-value.d.mts +5 -5
  8. package/dist/array/impl/array-utils-reducing-value.d.mts.map +1 -1
  9. package/dist/array/impl/array-utils-reducing-value.mjs +1 -0
  10. package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
  11. package/dist/array/impl/array-utils-search.d.mts +8 -8
  12. package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
  13. package/dist/array/impl/array-utils-set-op.mjs +3 -1
  14. package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
  15. package/dist/array/impl/array-utils-size.d.mts +1 -1
  16. package/dist/array/impl/array-utils-size.mjs +1 -1
  17. package/dist/array/impl/array-utils-slice-clamped.d.mts +1 -1
  18. package/dist/array/impl/array-utils-slicing.d.mts +3 -3
  19. package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
  20. package/dist/array/impl/array-utils-validation.d.mts +7 -7
  21. package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
  22. package/dist/array/impl/array-utils-validation.mjs +22 -12
  23. package/dist/array/impl/array-utils-validation.mjs.map +1 -1
  24. package/dist/collections/imap-mapped.d.mts +5 -12
  25. package/dist/collections/imap-mapped.d.mts.map +1 -1
  26. package/dist/collections/imap-mapped.mjs.map +1 -1
  27. package/dist/collections/imap.d.mts +24 -28
  28. package/dist/collections/imap.d.mts.map +1 -1
  29. package/dist/collections/imap.mjs +1 -1
  30. package/dist/collections/imap.mjs.map +1 -1
  31. package/dist/collections/iset-mapped.d.mts +8 -14
  32. package/dist/collections/iset-mapped.d.mts.map +1 -1
  33. package/dist/collections/iset-mapped.mjs.map +1 -1
  34. package/dist/collections/iset.d.mts +9 -23
  35. package/dist/collections/iset.d.mts.map +1 -1
  36. package/dist/collections/iset.mjs +1 -0
  37. package/dist/collections/iset.mjs.map +1 -1
  38. package/dist/entry-point.mjs +1 -0
  39. package/dist/entry-point.mjs.map +1 -1
  40. package/dist/functional/optional/impl/optional-is-optional.d.mts +1 -1
  41. package/dist/functional/optional/impl/optional-is-optional.d.mts.map +1 -1
  42. package/dist/functional/optional/impl/optional-is-optional.mjs +6 -5
  43. package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
  44. package/dist/functional/optional/impl/optional-some.d.mts.map +1 -1
  45. package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
  46. package/dist/functional/optional/impl/optional-zip.d.mts +1 -1
  47. package/dist/functional/optional/impl/optional-zip.mjs +1 -1
  48. package/dist/functional/result/impl/result-err.d.mts.map +1 -1
  49. package/dist/functional/result/impl/result-err.mjs.map +1 -1
  50. package/dist/functional/result/impl/result-is-result.d.mts +1 -1
  51. package/dist/functional/result/impl/result-is-result.mjs +1 -1
  52. package/dist/functional/result/impl/result-ok.d.mts.map +1 -1
  53. package/dist/functional/result/impl/result-ok.mjs.map +1 -1
  54. package/dist/functional/result/impl/result-unwrap-err-throw.mjs +1 -0
  55. package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
  56. package/dist/functional/result/impl/result-unwrap-throw.mjs +1 -0
  57. package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -1
  58. package/dist/functional/ternary-result/impl/ternary-result-err.d.mts.map +1 -1
  59. package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -1
  60. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts +1 -1
  61. package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +1 -1
  62. package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts.map +1 -1
  63. package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -1
  64. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +1 -0
  65. package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -1
  66. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +1 -0
  67. package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -1
  68. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +1 -0
  69. package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -1
  70. package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts.map +1 -1
  71. package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -1
  72. package/dist/guard/has-key.d.mts +3 -1
  73. package/dist/guard/has-key.d.mts.map +1 -1
  74. package/dist/guard/has-key.mjs +6 -2
  75. package/dist/guard/has-key.mjs.map +1 -1
  76. package/dist/guard/is-non-null-object.d.mts.map +1 -1
  77. package/dist/guard/is-non-null-object.mjs +3 -1
  78. package/dist/guard/is-non-null-object.mjs.map +1 -1
  79. package/dist/guard/is-record.d.mts +2 -2
  80. package/dist/guard/is-record.mjs +2 -2
  81. package/dist/guard/is-type.d.mts +15 -15
  82. package/dist/guard/is-type.mjs +15 -15
  83. package/dist/guard/key-is-in.d.mts.map +1 -1
  84. package/dist/guard/key-is-in.mjs +3 -1
  85. package/dist/guard/key-is-in.mjs.map +1 -1
  86. package/dist/index.mjs +1 -0
  87. package/dist/index.mjs.map +1 -1
  88. package/dist/json/json.d.mts +3 -3
  89. package/dist/json/json.mjs +4 -3
  90. package/dist/json/json.mjs.map +1 -1
  91. package/dist/number/branded-types/non-zero-safe-int.mjs +2 -2
  92. package/dist/number/branded-types/positive-safe-int.mjs +1 -1
  93. package/dist/number/branded-types/safe-int.mjs +2 -2
  94. package/dist/number/branded-types/safe-uint.mjs +1 -1
  95. package/dist/number/num.mjs +1 -1
  96. package/dist/object/object.d.mts +36 -8
  97. package/dist/object/object.d.mts.map +1 -1
  98. package/dist/object/object.mjs +28 -6
  99. package/dist/object/object.mjs.map +1 -1
  100. package/dist/others/fast-deep-equal.d.mts +8 -0
  101. package/dist/others/fast-deep-equal.d.mts.map +1 -0
  102. package/dist/others/fast-deep-equal.mjs +72 -0
  103. package/dist/others/fast-deep-equal.mjs.map +1 -0
  104. package/dist/others/index.d.mts +1 -0
  105. package/dist/others/index.d.mts.map +1 -1
  106. package/dist/others/index.mjs +1 -0
  107. package/dist/others/index.mjs.map +1 -1
  108. package/package.json +34 -29
  109. package/src/array/impl/array-utils-creation.test.mts +13 -10
  110. package/src/array/impl/array-utils-element-access.mts +5 -5
  111. package/src/array/impl/array-utils-element-access.test.mts +5 -5
  112. package/src/array/impl/array-utils-iterators.mts +1 -1
  113. package/src/array/impl/array-utils-iterators.test.mts +6 -6
  114. package/src/array/impl/array-utils-modification.mts +4 -4
  115. package/src/array/impl/array-utils-modification.test.mts +12 -12
  116. package/src/array/impl/array-utils-overload-type-error.test.mts +1 -1
  117. package/src/array/impl/array-utils-reducing-value.mts +6 -5
  118. package/src/array/impl/array-utils-reducing-value.test.mts +9 -9
  119. package/src/array/impl/array-utils-search.mts +8 -8
  120. package/src/array/impl/array-utils-search.test.mts +35 -35
  121. package/src/array/impl/array-utils-set-op.mts +1 -0
  122. package/src/array/impl/array-utils-set-op.test.mts +2 -2
  123. package/src/array/impl/array-utils-size.mts +1 -1
  124. package/src/array/impl/array-utils-size.test.mts +1 -1
  125. package/src/array/impl/array-utils-slice-clamped.mts +1 -1
  126. package/src/array/impl/array-utils-slice-clamped.test.mts +5 -5
  127. package/src/array/impl/array-utils-slicing.mts +3 -3
  128. package/src/array/impl/array-utils-slicing.test.mts +5 -5
  129. package/src/array/impl/array-utils-transformation.mts +1 -1
  130. package/src/array/impl/array-utils-transformation.test.mts +53 -53
  131. package/src/array/impl/array-utils-validation.mts +18 -10
  132. package/src/array/impl/array-utils-validation.test.mts +34 -29
  133. package/src/array/impl/array.test.mts +1 -1
  134. package/src/collections/imap-mapped.mts +4 -10
  135. package/src/collections/imap-mapped.test.mts +9 -9
  136. package/src/collections/imap.mts +24 -27
  137. package/src/collections/imap.test.mts +6 -6
  138. package/src/collections/iset-mapped.mts +12 -16
  139. package/src/collections/iset-mapped.test.mts +6 -6
  140. package/src/collections/iset.mts +14 -25
  141. package/src/collections/queue.test.mts +2 -1
  142. package/src/collections/stack.test.mts +3 -3
  143. package/src/functional/optional/impl/optional-is-optional.mts +6 -6
  144. package/src/functional/optional/impl/optional-some.mts +5 -4
  145. package/src/functional/optional/impl/optional-zip.mts +1 -1
  146. package/src/functional/result/impl/result-err.mts +5 -4
  147. package/src/functional/result/impl/result-is-result.mts +1 -1
  148. package/src/functional/result/impl/result-ok.mts +5 -4
  149. package/src/functional/result.test.mts +2 -2
  150. package/src/functional/ternary-result/impl/ternary-result-err.mts +5 -4
  151. package/src/functional/ternary-result/impl/ternary-result-is-ternary-result.mts +1 -1
  152. package/src/functional/ternary-result/impl/ternary-result-ok.mts +5 -4
  153. package/src/functional/ternary-result/impl/ternary-result-warn.mts +6 -5
  154. package/src/guard/has-key.mts +6 -2
  155. package/src/guard/is-error.test.mts +1 -1
  156. package/src/guard/is-non-empty-string.test.mts +1 -1
  157. package/src/guard/is-non-null-object.mts +1 -0
  158. package/src/guard/is-non-null-object.test.mts +4 -3
  159. package/src/guard/is-primitive.test.mts +1 -1
  160. package/src/guard/is-record.mts +2 -2
  161. package/src/guard/is-record.test.mts +2 -2
  162. package/src/guard/is-type.mts +15 -15
  163. package/src/guard/is-type.test.mts +2 -2
  164. package/src/guard/key-is-in.mts +3 -1
  165. package/src/json/json.mts +4 -3
  166. package/src/json/json.test.mts +20 -19
  167. package/src/number/branded-types/non-zero-safe-int.mts +2 -2
  168. package/src/number/branded-types/positive-safe-int.mts +1 -1
  169. package/src/number/branded-types/safe-int.mts +2 -2
  170. package/src/number/branded-types/safe-uint.mts +1 -1
  171. package/src/number/num.mts +1 -1
  172. package/src/object/object.mts +54 -8
  173. package/src/object/object.test.mts +70 -7
  174. package/src/others/cast-mutable.test.mts +3 -3
  175. package/src/others/cast-readonly.test.mts +10 -5
  176. package/src/others/fast-deep-equal.mts +98 -0
  177. package/src/others/fast-deep-equal.test.mts +771 -0
  178. package/src/others/index.mts +1 -0
  179. package/src/others/map-nullable.test.mts +8 -8
  180. package/src/others/memoize-function.test.mts +20 -8
  181. package/src/others/unknown-to-string.test.mts +8 -8
@@ -4,7 +4,7 @@ import { entries, indices, values } from './array-utils-iterators.mjs';
4
4
 
5
5
  describe(entries, () => {
6
6
  test('should return array of index-value pairs', () => {
7
- const fruits = ['apple', 'banana', 'cherry'];
7
+ const fruits = ['apple', 'banana', 'cherry'] as const;
8
8
 
9
9
  const es = Array.from(entries(fruits));
10
10
 
@@ -31,7 +31,7 @@ describe(entries, () => {
31
31
  });
32
32
 
33
33
  test('should work with empty array', () => {
34
- const empty: readonly string[] = [];
34
+ const empty: readonly string[] = [] as const;
35
35
 
36
36
  const es = Array.from(entries(empty));
37
37
 
@@ -56,7 +56,7 @@ describe(entries, () => {
56
56
 
57
57
  describe(values, () => {
58
58
  test('should return copy of array values', () => {
59
- const numbers = [1, 2, 3];
59
+ const numbers = [1, 2, 3] as const;
60
60
 
61
61
  const vs = Array.from(values(numbers));
62
62
 
@@ -77,7 +77,7 @@ describe(values, () => {
77
77
  });
78
78
 
79
79
  test('should work with empty array', () => {
80
- const empty: readonly number[] = [];
80
+ const empty: readonly number[] = [] as const;
81
81
 
82
82
  const vs = Array.from(values(empty));
83
83
 
@@ -98,7 +98,7 @@ describe(values, () => {
98
98
 
99
99
  describe(indices, () => {
100
100
  test('should return array of indices', () => {
101
- const fruits = ['apple', 'banana', 'cherry'];
101
+ const fruits = ['apple', 'banana', 'cherry'] as const;
102
102
 
103
103
  const ks = Array.from(indices(fruits));
104
104
 
@@ -117,7 +117,7 @@ describe(indices, () => {
117
117
  });
118
118
 
119
119
  test('should work with empty array', () => {
120
- const empty: readonly string[] = [];
120
+ const empty: readonly string[] = [] as const;
121
121
 
122
122
  const ks = Array.from(indices(empty));
123
123
 
@@ -8,7 +8,7 @@ import { copy, create } from './array-utils-creation.mjs';
8
8
  * @example
9
9
  *
10
10
  * ```ts
11
- * const scores: readonly number[] = [10, 20, 30];
11
+ * const scores: readonly number[] = [10, 20, 30] as const;
12
12
  *
13
13
  * const updated = Arr.set(scores, 1, 25);
14
14
  *
@@ -63,7 +63,7 @@ export function set<E, const V = E>(
63
63
  * @example
64
64
  *
65
65
  * ```ts
66
- * const temperatures: readonly number[] = [20, 21, 22];
66
+ * const temperatures: readonly number[] = [20, 21, 22] as const;
67
67
  *
68
68
  * const increased = Arr.toUpdated(temperatures, 1, (value) => value + 5);
69
69
  *
@@ -341,7 +341,7 @@ export function toUnshifted<Ar extends readonly unknown[], const V>(
341
341
  * @example
342
342
  *
343
343
  * ```ts
344
- * const base = [1, 2, 3];
344
+ * const base = [1, 2, 3] as const;
345
345
  *
346
346
  * const filled = Arr.toFilled(base, 0);
347
347
  *
@@ -396,7 +396,7 @@ export function toFilled<E>(
396
396
  * @example
397
397
  *
398
398
  * ```ts
399
- * const base = [0, 1, 2, 3, 4];
399
+ * const base = [0, 1, 2, 3, 4] as const;
400
400
  *
401
401
  * const filledMiddle = Arr.toRangeFilled(base, 9, [1, 4]);
402
402
  *
@@ -104,7 +104,7 @@ describe('Arr modifications', () => {
104
104
  });
105
105
 
106
106
  test('case 4 (number[])', () => {
107
- const xs: readonly number[] = [1, 2, 3];
107
+ const xs: readonly number[] = [1, 2, 3] as const;
108
108
 
109
109
  const result = toRemoved(xs, 5);
110
110
 
@@ -134,7 +134,7 @@ describe('Arr modifications', () => {
134
134
  });
135
135
 
136
136
  test('case 2', () => {
137
- const xs: readonly number[] = [1, 2, 3];
137
+ const xs: readonly number[] = [1, 2, 3] as const;
138
138
 
139
139
  const result = toPushed(xs, 4 as const);
140
140
 
@@ -164,7 +164,7 @@ describe('Arr modifications', () => {
164
164
  });
165
165
 
166
166
  test('case 2', () => {
167
- const xs: readonly number[] = [1, 2, 3];
167
+ const xs: readonly number[] = [1, 2, 3] as const;
168
168
 
169
169
  const result = toUnshifted(xs, 4 as const);
170
170
 
@@ -184,7 +184,7 @@ describe('Arr modifications', () => {
184
184
 
185
185
  describe(toFilled, () => {
186
186
  test('should fill entire array with value', () => {
187
- const arr = [1, 2, 3, 4, 5];
187
+ const arr = [1, 2, 3, 4, 5] as const;
188
188
 
189
189
  const result = toFilled(arr, 0);
190
190
 
@@ -194,7 +194,7 @@ describe('Arr modifications', () => {
194
194
  test('should work with curried version', () => {
195
195
  const fillWithZero = toFilled(0);
196
196
 
197
- const arr = [1, 2, 3];
197
+ const arr = [1, 2, 3] as const;
198
198
 
199
199
  const result = fillWithZero(arr);
200
200
 
@@ -204,7 +204,7 @@ describe('Arr modifications', () => {
204
204
 
205
205
  describe(toRangeFilled, () => {
206
206
  test('should fill array with range', () => {
207
- const arr = [1, 2, 3, 4, 5];
207
+ const arr = [1, 2, 3, 4, 5] as const;
208
208
 
209
209
  const result = toRangeFilled(arr, 0, [1, 4]);
210
210
 
@@ -212,7 +212,7 @@ describe('Arr modifications', () => {
212
212
  });
213
213
 
214
214
  test('should fill with range starting from 0', () => {
215
- const arr = [1, 2, 3, 4, 5];
215
+ const arr = [1, 2, 3, 4, 5] as const;
216
216
 
217
217
  const result = toRangeFilled(arr, 9, [0, 3]);
218
218
 
@@ -220,7 +220,7 @@ describe('Arr modifications', () => {
220
220
  });
221
221
 
222
222
  test('should handle empty range', () => {
223
- const arr = [1, 2, 3];
223
+ const arr = [1, 2, 3] as const;
224
224
 
225
225
  const result = toRangeFilled(arr, 0, [2, 2]);
226
226
 
@@ -228,7 +228,7 @@ describe('Arr modifications', () => {
228
228
  });
229
229
 
230
230
  test('should clamp range to array bounds', () => {
231
- const arr = [1, 2, 3];
231
+ const arr = [1, 2, 3] as readonly number[];
232
232
 
233
233
  const result = toRangeFilled(arr, 0, [1, 10]);
234
234
 
@@ -236,7 +236,7 @@ describe('Arr modifications', () => {
236
236
  });
237
237
 
238
238
  test('should handle negative start (clamped to 0)', () => {
239
- const arr = [1, 2, 3];
239
+ const arr = [1, 2, 3] as readonly number[];
240
240
 
241
241
  const result = toRangeFilled(arr, 9, [-5, 2]);
242
242
 
@@ -252,14 +252,14 @@ describe('Arr modifications', () => {
252
252
  });
253
253
 
254
254
  test('A non-integer starting value should result in a type error', () => {
255
- const arr = [1, 2, 3];
255
+ const arr = [1, 2, 3] as const;
256
256
 
257
257
  // @ts-expect-error start must be an integer
258
258
  assert.deepStrictEqual(toRangeFilled(arr, 0, [1.5, 3]), [1, 0, 0]);
259
259
  });
260
260
 
261
261
  test('A non-integer ending value should result in a type error', () => {
262
- const arr = [1, 2, 3];
262
+ const arr = [1, 2, 3] as const;
263
263
 
264
264
  // @ts-expect-error end must be an integer
265
265
  assert.deepStrictEqual(toRangeFilled(arr, 0, [1, 2.5]), [1, 0, 3]);
@@ -148,7 +148,7 @@ describe('Array overloaded functions - type error validation', () => {
148
148
  const invalidArgs: readonly [readonly string[], (x: string) => number] = [
149
149
  ['a'],
150
150
  (x) => x.length,
151
- ];
151
+ ] as const;
152
152
 
153
153
  // @ts-expect-error - Wrong types in tuple for spread
154
154
  findIndex(...invalidArgs);
@@ -14,7 +14,7 @@ import { isNonEmpty } from './array-utils-validation.mjs';
14
14
  * ```ts
15
15
  * const values = [5, 3, 9] as const;
16
16
  *
17
- * const empty: readonly number[] = [];
17
+ * const empty: readonly number[] = [] as const;
18
18
  *
19
19
  * const smallest = Arr.min(values);
20
20
  *
@@ -64,7 +64,7 @@ export function min<E extends number>(
64
64
  * @example
65
65
  *
66
66
  * ```ts
67
- * const values = [5, 3, 9];
67
+ * const values = [5, 3, 9] as const;
68
68
  *
69
69
  * const largest = Arr.max(values);
70
70
  *
@@ -155,7 +155,7 @@ export function minBy<E, V>(
155
155
  * { id: 'a', stars: 10 },
156
156
  * { id: 'b', stars: 30 },
157
157
  * { id: 'c', stars: 20 },
158
- * ];
158
+ * ] as const;
159
159
  *
160
160
  * const mostStars = Arr.maxBy(projects, (project) => project.stars);
161
161
  *
@@ -318,7 +318,7 @@ export function countBy<E, G extends MapSetKeyType>(
318
318
  * @example
319
319
  *
320
320
  * ```ts
321
- * const words = ['Ada', 'Lovelace'];
321
+ * const words = ['Ada', 'Lovelace'] as const;
322
322
  *
323
323
  * const totalLength = Arr.foldl(words, (acc, word) => acc + word.length, 0);
324
324
  *
@@ -395,7 +395,7 @@ export function foldl<E, P>(
395
395
  * @example
396
396
  *
397
397
  * ```ts
398
- * const numbers = [1, 2, 3];
398
+ * const numbers = [1, 2, 3] as const;
399
399
  *
400
400
  * const subtractRight = Arr.foldr(numbers, (acc, value) => acc - value, 0);
401
401
  *
@@ -496,6 +496,7 @@ export function sum(array: readonly Int[]): Int;
496
496
  export function sum(array: readonly number[]): number;
497
497
 
498
498
  export function sum(array: readonly number[]): number {
499
+ // eslint-disable-next-line ts-data-forge/prefer-arr-sum
499
500
  return array.reduce((prev, curr) => prev + curr, 0);
500
501
  }
501
502
 
@@ -93,7 +93,7 @@ describe('Arr reducing value', () => {
93
93
  });
94
94
 
95
95
  test('case 3: readonly array', () => {
96
- const arr: readonly number[] = [1, 5, 2];
96
+ const arr: readonly number[] = [1, 5, 2] as const;
97
97
 
98
98
  const res = max(arr);
99
99
 
@@ -107,7 +107,7 @@ describe('Arr reducing value', () => {
107
107
  });
108
108
 
109
109
  test('case 4: empty array', () => {
110
- const arr: readonly number[] = [];
110
+ const arr: readonly number[] = [] as const;
111
111
 
112
112
  const res = max(arr);
113
113
 
@@ -152,7 +152,7 @@ describe('Arr reducing value', () => {
152
152
  });
153
153
 
154
154
  test('case 2: empty array', () => {
155
- const arr: readonly Readonly<{ x: number }>[] = [];
155
+ const arr: readonly Readonly<{ x: number }>[] = [] as const;
156
156
 
157
157
  const res = minBy(arr, (a) => a.x);
158
158
 
@@ -228,7 +228,7 @@ describe('Arr reducing value', () => {
228
228
  });
229
229
 
230
230
  test('case 2: empty array', () => {
231
- const arr: readonly Readonly<{ x: number }>[] = [];
231
+ const arr: readonly Readonly<{ x: number }>[] = [] as const;
232
232
 
233
233
  const res = maxBy(arr, (a) => a.x);
234
234
 
@@ -288,7 +288,7 @@ describe('Arr reducing value', () => {
288
288
  });
289
289
 
290
290
  test('case 2: empty array', () => {
291
- const arr: readonly number[] = [];
291
+ const arr: readonly number[] = [] as const;
292
292
 
293
293
  const res = count(arr, (x) => x > 0);
294
294
 
@@ -332,7 +332,7 @@ describe('Arr reducing value', () => {
332
332
  });
333
333
 
334
334
  test('case 2: empty array', () => {
335
- const arr: readonly Readonly<{ x: number }>[] = [];
335
+ const arr: readonly Readonly<{ x: number }>[] = [] as const;
336
336
 
337
337
  const res = countBy(arr, (a) => a.x);
338
338
 
@@ -485,7 +485,7 @@ describe('Arr reducing value', () => {
485
485
 
486
486
  describe(join, () => {
487
487
  test('should join array elements', () => {
488
- const arr = ['Hello', 'World'];
488
+ const arr = ['Hello', 'World'] as const;
489
489
 
490
490
  const result = join(arr, ' ');
491
491
 
@@ -495,7 +495,7 @@ describe('Arr reducing value', () => {
495
495
  });
496
496
 
497
497
  test('should handle empty separator', () => {
498
- const arr = ['a', 'b', 'c'];
498
+ const arr = ['a', 'b', 'c'] as const;
499
499
 
500
500
  const result = join(arr, '');
501
501
 
@@ -505,7 +505,7 @@ describe('Arr reducing value', () => {
505
505
  });
506
506
 
507
507
  test('should handle undefined separator', () => {
508
- const arr = ['a', 'b', 'c'];
508
+ const arr = ['a', 'b', 'c'] as const;
509
509
 
510
510
  const result = join(arr);
511
511
 
@@ -11,7 +11,7 @@ import { asUint32 } from '../../number/index.mjs';
11
11
  * const users = [
12
12
  * { id: 1, name: 'Ada' },
13
13
  * { id: 2, name: 'Grace' },
14
- * ];
14
+ * ] as const;
15
15
  *
16
16
  * const found = Arr.find(users, (user) => user.id === 2);
17
17
  *
@@ -100,7 +100,7 @@ export function find<E>(
100
100
  * @example
101
101
  *
102
102
  * ```ts
103
- * const numbers = [1, 3, 2, 4, 5];
103
+ * const numbers = [1, 3, 2, 4, 5] as const;
104
104
  *
105
105
  * const lastEven = Arr.findLast(numbers, (n) => n % 2 === 0);
106
106
  *
@@ -187,7 +187,7 @@ export function findLast<E>(
187
187
  * @example
188
188
  *
189
189
  * ```ts
190
- * const letters = ['a', 'b', 'c'];
190
+ * const letters = ['a', 'b', 'c'] as const;
191
191
  *
192
192
  * const indexOfB = Arr.findIndex(letters, (letter) => letter === 'b');
193
193
  *
@@ -254,7 +254,7 @@ export function findIndex<E>(
254
254
  * @example
255
255
  *
256
256
  * ```ts
257
- * const letters = ['a', 'b', 'c', 'b'];
257
+ * const letters = ['a', 'b', 'c', 'b'] as const;
258
258
  *
259
259
  * const lastIndexOfB = Arr.findLastIndex(letters, (letter) => letter === 'b');
260
260
  *
@@ -321,7 +321,7 @@ export function findLastIndex<E>(
321
321
  * @example
322
322
  *
323
323
  * ```ts
324
- * const fruits = ['apple', 'banana', 'orange', 'banana'];
324
+ * const fruits = ['apple', 'banana', 'orange', 'banana'] as readonly string[];
325
325
  *
326
326
  * const indexOfBanana = Arr.indexOf(fruits, 'banana');
327
327
  *
@@ -376,7 +376,7 @@ export function indexOf<E>(
376
376
  * @example
377
377
  *
378
378
  * ```ts
379
- * const fruits = ['apple', 'banana', 'orange', 'banana'];
379
+ * const fruits = ['apple', 'banana', 'orange', 'banana'] as readonly string[];
380
380
  *
381
381
  * // Search for 'banana' starting from index 1
382
382
  * const firstBanana = Arr.indexOfFrom(fruits, 'banana', 1);
@@ -444,7 +444,7 @@ export function indexOfFrom<E>(
444
444
  * @example
445
445
  *
446
446
  * ```ts
447
- * const fruits = ['apple', 'banana', 'orange', 'banana'];
447
+ * const fruits = ['apple', 'banana', 'orange', 'banana'] as readonly string[];
448
448
  *
449
449
  * const lastBanana = Arr.lastIndexOf(fruits, 'banana');
450
450
  *
@@ -503,7 +503,7 @@ export function lastIndexOf<E>(
503
503
  * @example
504
504
  *
505
505
  * ```ts
506
- * const fruits = ['apple', 'banana', 'orange', 'banana', 'grape'];
506
+ * const fruits = ['apple', 'banana', 'orange', 'banana', 'grape'] as const;
507
507
  *
508
508
  * // Search backwards for 'banana' from index 3
509
509
  * const lastBananaFrom3 = Arr.lastIndexOfFrom(fruits, 'banana', 3);