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
@@ -14,7 +14,7 @@ import {
14
14
  describe('Arr search operations', () => {
15
15
  describe(find, () => {
16
16
  test('should find first element matching predicate', () => {
17
- const numbers = [1, 2, 3, 4, 5];
17
+ const numbers = [1, 2, 3, 4, 5] as const;
18
18
 
19
19
  const firstEven = find(numbers, (n) => n % 2 === 0);
20
20
 
@@ -24,7 +24,7 @@ describe('Arr search operations', () => {
24
24
  });
25
25
 
26
26
  test('should return None when no element matches', () => {
27
- const odds = [1, 3, 5];
27
+ const odds = [1, 3, 5] as const;
28
28
 
29
29
  const firstEven = find(odds, (n) => n % 2 === 0);
30
30
 
@@ -48,7 +48,7 @@ describe('Arr search operations', () => {
48
48
  });
49
49
 
50
50
  test('should work with type guard predicate', () => {
51
- const values: readonly (string | number)[] = [1, 'a', 2, 'b'];
51
+ const values: readonly (string | number)[] = [1, 'a', 2, 'b'] as const;
52
52
 
53
53
  const firstString = find(
54
54
  values,
@@ -63,7 +63,7 @@ describe('Arr search operations', () => {
63
63
  });
64
64
 
65
65
  test('should provide index and array to predicate', () => {
66
- const numbers = [10, 20, 30];
66
+ const numbers = [10, 20, 30] as readonly number[];
67
67
 
68
68
  const foundWithIndex = find(numbers, (value, index, arr) => {
69
69
  expect(arr).toBe(numbers);
@@ -75,7 +75,7 @@ describe('Arr search operations', () => {
75
75
  });
76
76
 
77
77
  test('should return first match when multiple elements match', () => {
78
- const numbers = [2, 4, 6, 8];
78
+ const numbers = [2, 4, 6, 8] as const;
79
79
 
80
80
  const firstEven = find(numbers, (n) => n % 2 === 0);
81
81
 
@@ -83,7 +83,7 @@ describe('Arr search operations', () => {
83
83
  });
84
84
 
85
85
  test('should work with empty array', () => {
86
- const empty: readonly number[] = [];
86
+ const empty: readonly number[] = [] as const;
87
87
 
88
88
  const result = find(empty, () => true);
89
89
 
@@ -93,7 +93,7 @@ describe('Arr search operations', () => {
93
93
 
94
94
  describe(findLast, () => {
95
95
  test('should find last element matching predicate', () => {
96
- const numbers = [1, 2, 3, 4, 5];
96
+ const numbers = [1, 2, 3, 4, 5] as const;
97
97
 
98
98
  const lastEven = findLast(numbers, (n) => n % 2 === 0);
99
99
 
@@ -103,7 +103,7 @@ describe('Arr search operations', () => {
103
103
  });
104
104
 
105
105
  test('should return None when no element matches', () => {
106
- const odds = [1, 3, 5];
106
+ const odds = [1, 3, 5] as const;
107
107
 
108
108
  const lastEven = findLast(odds, (n) => n % 2 === 0);
109
109
 
@@ -123,7 +123,7 @@ describe('Arr search operations', () => {
123
123
  });
124
124
 
125
125
  test('should work with empty array', () => {
126
- const empty: readonly number[] = [];
126
+ const empty: readonly number[] = [] as const;
127
127
 
128
128
  const result = findLast(empty, (n) => n > 0);
129
129
 
@@ -131,7 +131,7 @@ describe('Arr search operations', () => {
131
131
  });
132
132
 
133
133
  test('should pass index and array to predicate', () => {
134
- const numbers = [10, 20, 30, 40];
134
+ const numbers = [10, 20, 30, 40] as readonly number[];
135
135
 
136
136
  const lastWithIndex2 = findLast(numbers, (_, idx, arr) => {
137
137
  expect(arr).toBe(numbers);
@@ -143,7 +143,7 @@ describe('Arr search operations', () => {
143
143
  });
144
144
 
145
145
  test('should find last occurrence', () => {
146
- const numbers = [1, 2, 2, 3, 2, 4];
146
+ const numbers = [1, 2, 2, 3, 2, 4] as const;
147
147
 
148
148
  const lastTwo = findLast(numbers, (n) => n === 2);
149
149
 
@@ -158,7 +158,7 @@ describe('Arr search operations', () => {
158
158
 
159
159
  describe(findIndex, () => {
160
160
  test('should find index of matching element', () => {
161
- const arr = ['a', 'b', 'c'];
161
+ const arr = ['a', 'b', 'c'] as readonly string[];
162
162
 
163
163
  const result = findIndex(arr, (x) => x === 'b');
164
164
 
@@ -170,7 +170,7 @@ describe('Arr search operations', () => {
170
170
  });
171
171
 
172
172
  test('should return None for no match', () => {
173
- const arr = ['a', 'b', 'c'];
173
+ const arr = ['a', 'b', 'c'] as readonly string[];
174
174
 
175
175
  const result = findIndex(arr, (x) => x === 'd');
176
176
 
@@ -180,7 +180,7 @@ describe('Arr search operations', () => {
180
180
 
181
181
  describe(findLastIndex, () => {
182
182
  test('should find last index matching predicate', () => {
183
- const numbers = [1, 2, 3, 4, 2, 5];
183
+ const numbers = [1, 2, 3, 4, 2, 5] as const;
184
184
 
185
185
  const lastTwoIndex = findLastIndex(numbers, (n) => n === 2);
186
186
 
@@ -188,7 +188,7 @@ describe('Arr search operations', () => {
188
188
  });
189
189
 
190
190
  test('should return -1 when no element matches', () => {
191
- const odds = [1, 3, 5];
191
+ const odds = [1, 3, 5] as const;
192
192
 
193
193
  const lastEvenIndex = findLastIndex(odds, (n) => n % 2 === 0);
194
194
 
@@ -206,7 +206,7 @@ describe('Arr search operations', () => {
206
206
  });
207
207
 
208
208
  test('should work with empty array', () => {
209
- const empty: readonly number[] = [];
209
+ const empty: readonly number[] = [] as const;
210
210
 
211
211
  const result = findLastIndex(empty, (n) => n > 0);
212
212
 
@@ -214,7 +214,7 @@ describe('Arr search operations', () => {
214
214
  });
215
215
 
216
216
  test('should pass index and array to predicate', () => {
217
- const numbers = [10, 20, 30, 40];
217
+ const numbers = [10, 20, 30, 40] as const;
218
218
 
219
219
  const lastWithIndex2OrHigher = findLastIndex(numbers, (_, idx, arr) => {
220
220
  expect(arr).toBe(numbers);
@@ -232,7 +232,7 @@ describe('Arr search operations', () => {
232
232
  { id: 3, active: true },
233
233
  { id: 4, active: false },
234
234
  { id: 5, active: true },
235
- ];
235
+ ] as const;
236
236
 
237
237
  const lastActiveIndex = findLastIndex(data, (item) => item.active);
238
238
 
@@ -249,7 +249,7 @@ describe('Arr search operations', () => {
249
249
 
250
250
  test('should search from end to beginning', () => {
251
251
  // Verify search order by using side effects
252
- const numbers = [1, 2, 3, 4, 5];
252
+ const numbers = [1, 2, 3, 4, 5] as const;
253
253
 
254
254
  const mut_searchOrder: number[] = [];
255
255
 
@@ -264,7 +264,7 @@ describe('Arr search operations', () => {
264
264
  });
265
265
 
266
266
  test('should handle single element array', () => {
267
- const single = [42];
267
+ const single = [42] as readonly number[];
268
268
 
269
269
  const foundIndex = findLastIndex(single, (n) => n === 42);
270
270
 
@@ -276,7 +276,7 @@ describe('Arr search operations', () => {
276
276
  });
277
277
 
278
278
  test('should work with string arrays', () => {
279
- const words = ['hello', 'world', 'test', 'hello', 'end'];
279
+ const words = ['hello', 'world', 'test', 'hello', 'end'] as const;
280
280
 
281
281
  const lastHelloIndex = findLastIndex(words, (word) => word === 'hello');
282
282
 
@@ -286,7 +286,7 @@ describe('Arr search operations', () => {
286
286
 
287
287
  describe(indexOf, () => {
288
288
  test('should find index of element', () => {
289
- const arr = ['a', 'b', 'c', 'b'];
289
+ const arr = ['a', 'b', 'c', 'b'] as readonly string[];
290
290
 
291
291
  const result = indexOf(arr, 'b');
292
292
 
@@ -300,7 +300,7 @@ describe('Arr search operations', () => {
300
300
  });
301
301
 
302
302
  test('should return -1 for non-existent element', () => {
303
- const arr = ['a', 'b', 'c'];
303
+ const arr = ['a', 'b', 'c'] as readonly string[];
304
304
 
305
305
  const result = indexOf(arr, 'd');
306
306
 
@@ -310,7 +310,7 @@ describe('Arr search operations', () => {
310
310
 
311
311
  describe(indexOfFrom, () => {
312
312
  test('should find index of element from specified index', () => {
313
- const arr = ['a', 'b', 'c', 'b'];
313
+ const arr = ['a', 'b', 'c', 'b'] as readonly string[];
314
314
 
315
315
  const result = indexOfFrom(arr, 'b', 2);
316
316
 
@@ -324,7 +324,7 @@ describe('Arr search operations', () => {
324
324
  });
325
325
 
326
326
  test('should return -1 when element not found from index', () => {
327
- const arr = ['a', 'b', 'c', 'b'];
327
+ const arr = ['a', 'b', 'c', 'b'] as const;
328
328
 
329
329
  const result = indexOfFrom(arr, 'a', 1);
330
330
 
@@ -332,7 +332,7 @@ describe('Arr search operations', () => {
332
332
  });
333
333
 
334
334
  test('should find first occurrence when fromIndex is 0', () => {
335
- const arr = ['a', 'b', 'c', 'b'];
335
+ const arr = ['a', 'b', 'c', 'b'] as const;
336
336
 
337
337
  const result = indexOfFrom(arr, 'b', 0);
338
338
 
@@ -340,7 +340,7 @@ describe('Arr search operations', () => {
340
340
  });
341
341
 
342
342
  test('should handle negative fromIndex', () => {
343
- const arr = ['a', 'b', 'c', 'b'];
343
+ const arr = ['a', 'b', 'c', 'b'] as const;
344
344
 
345
345
  const result = indexOfFrom(arr, 'b', -2);
346
346
 
@@ -348,7 +348,7 @@ describe('Arr search operations', () => {
348
348
  });
349
349
 
350
350
  test('should handle fromIndex beyond array length', () => {
351
- const arr = ['a', 'b', 'c'];
351
+ const arr = ['a', 'b', 'c'] as readonly string[];
352
352
 
353
353
  const result = indexOfFrom(arr, 'a', 10);
354
354
 
@@ -358,7 +358,7 @@ describe('Arr search operations', () => {
358
358
 
359
359
  describe(lastIndexOf, () => {
360
360
  test('should find last index of element', () => {
361
- const arr = ['a', 'b', 'c', 'b'];
361
+ const arr = ['a', 'b', 'c', 'b'] as readonly string[];
362
362
 
363
363
  const result = lastIndexOf(arr, 'b');
364
364
 
@@ -372,7 +372,7 @@ describe('Arr search operations', () => {
372
372
  });
373
373
 
374
374
  test('should return -1 for non-existent element', () => {
375
- const arr = ['a', 'b', 'c'];
375
+ const arr = ['a', 'b', 'c'] as readonly string[];
376
376
 
377
377
  const result = lastIndexOf(arr, 'd');
378
378
 
@@ -382,7 +382,7 @@ describe('Arr search operations', () => {
382
382
 
383
383
  describe(lastIndexOfFrom, () => {
384
384
  test('should find last index of element from specified index', () => {
385
- const arr = ['a', 'b', 'c', 'b', 'e'];
385
+ const arr = ['a', 'b', 'c', 'b', 'e'] as readonly string[];
386
386
 
387
387
  const result = lastIndexOfFrom(arr, 'b', 2);
388
388
 
@@ -396,7 +396,7 @@ describe('Arr search operations', () => {
396
396
  });
397
397
 
398
398
  test('should return -1 when element not found before index', () => {
399
- const arr = ['a', 'b', 'c', 'b'];
399
+ const arr = ['a', 'b', 'c', 'b'] as const;
400
400
 
401
401
  const result = lastIndexOfFrom(arr, 'b', 0);
402
402
 
@@ -404,7 +404,7 @@ describe('Arr search operations', () => {
404
404
  });
405
405
 
406
406
  test('should find last occurrence when fromIndex covers all elements', () => {
407
- const arr = ['a', 'b', 'c', 'b'];
407
+ const arr = ['a', 'b', 'c', 'b'] as readonly string[];
408
408
 
409
409
  const result = lastIndexOfFrom(arr, 'b', 10);
410
410
 
@@ -412,7 +412,7 @@ describe('Arr search operations', () => {
412
412
  });
413
413
 
414
414
  test('should handle negative fromIndex', () => {
415
- const arr = ['a', 'b', 'c', 'b'];
415
+ const arr = ['a', 'b', 'c', 'b'] as const;
416
416
 
417
417
  const result = lastIndexOfFrom(arr, 'b', -1);
418
418
 
@@ -420,7 +420,7 @@ describe('Arr search operations', () => {
420
420
  });
421
421
 
422
422
  test('should handle fromIndex of 0', () => {
423
- const arr = ['a', 'b', 'c', 'b'];
423
+ const arr = ['a', 'b', 'c', 'b'] as const;
424
424
 
425
425
  const result = lastIndexOfFrom(arr, 'a', 0);
426
426
 
@@ -20,6 +20,7 @@ export const eq = <E,>(
20
20
  array2: readonly E[],
21
21
  equality: (a: E, b: E) => boolean = Object.is,
22
22
  ): boolean =>
23
+ // eslint-disable-next-line ts-data-forge/prefer-arr-is-array-of-length
23
24
  array1.length === array2.length &&
24
25
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
25
26
  array1.every((v, i) => equality(v, array2[i]!));
@@ -96,9 +96,9 @@ describe('Arr set operations', () => {
96
96
  }
97
97
 
98
98
  {
99
- const objA = { a: 1 };
99
+ const objA = { a: 1 } as const;
100
100
 
101
- const objB = { b: 2 };
101
+ const objB = { b: 2 } as const;
102
102
 
103
103
  const xs = [objA, objB] as const;
104
104
 
@@ -6,7 +6,7 @@
6
6
  * ```ts
7
7
  * const numbers = [1, 2, 3] as const;
8
8
  *
9
- * const letters: readonly string[] = [];
9
+ * const letters: readonly string[] = [] as const;
10
10
  *
11
11
  * const sizeOfNumbers = Arr.size(numbers);
12
12
  *
@@ -2,7 +2,7 @@ import { length, size } from './array-utils-size.mjs';
2
2
 
3
3
  describe('size/length', () => {
4
4
  test('size should return the array length', () => {
5
- const array = [1, 2, 3];
5
+ const array = [1, 2, 3] as const;
6
6
 
7
7
  expect(size(array)).toBe(array.length);
8
8
 
@@ -6,7 +6,7 @@ import { Num } from '../../number/index.mjs';
6
6
  * @example
7
7
  *
8
8
  * ```ts
9
- * const letters = ['a', 'b', 'c', 'd', 'e'];
9
+ * const letters = ['a', 'b', 'c', 'd', 'e'] as readonly string[];
10
10
  *
11
11
  * const lastThree = Arr.sliceClamped(letters, -3, 10);
12
12
  *
@@ -116,7 +116,7 @@ describe('Arr', () => {
116
116
  });
117
117
 
118
118
  test('should slice with clamped indices', () => {
119
- const array = [1, 2, 3, 4, 5];
119
+ const array = [1, 2, 3, 4, 5] as const;
120
120
 
121
121
  const result = sliceClamped(array, 1, 3);
122
122
 
@@ -124,7 +124,7 @@ describe('Arr', () => {
124
124
  });
125
125
 
126
126
  test('should clamp start index below 0', () => {
127
- const array = [1, 2, 3, 4, 5];
127
+ const array = [1, 2, 3, 4, 5] as readonly number[];
128
128
 
129
129
  const result = sliceClamped(array, -10, 3);
130
130
 
@@ -132,7 +132,7 @@ describe('Arr', () => {
132
132
  });
133
133
 
134
134
  test('should clamp end index above length', () => {
135
- const array = [1, 2, 3, 4, 5];
135
+ const array = [1, 2, 3, 4, 5] as readonly number[];
136
136
 
137
137
  const result = sliceClamped(array, asUint32(2), asUint32(100));
138
138
 
@@ -140,7 +140,7 @@ describe('Arr', () => {
140
140
  });
141
141
 
142
142
  test('should work with both indices out of range', () => {
143
- const array = [1, 2, 3];
143
+ const array = [1, 2, 3] as readonly number[];
144
144
 
145
145
  const result = sliceClamped(array, asInt32(-10), asUint32(100));
146
146
 
@@ -148,7 +148,7 @@ describe('Arr', () => {
148
148
  });
149
149
 
150
150
  test('should work with empty array', () => {
151
- const array: readonly number[] = [];
151
+ const array: readonly number[] = [] as const;
152
152
 
153
153
  const result = sliceClamped(array, 0, 5);
154
154
 
@@ -65,7 +65,7 @@ export const butLast = <const Ar extends readonly unknown[]>(
65
65
  * @example
66
66
  *
67
67
  * ```ts
68
- * const values = [1, 2, 3, 4];
68
+ * const values = [1, 2, 3, 4] as const;
69
69
  *
70
70
  * const firstTwo = Arr.take(values, 2);
71
71
  *
@@ -128,7 +128,7 @@ export function take<E>(
128
128
  * @example
129
129
  *
130
130
  * ```ts
131
- * const values = [1, 2, 3, 4];
131
+ * const values = [1, 2, 3, 4] as const;
132
132
  *
133
133
  * const lastTwo = Arr.takeLast(values, 2);
134
134
  *
@@ -241,7 +241,7 @@ export function skip<E>(
241
241
  * @example
242
242
  *
243
243
  * ```ts
244
- * const values = ['a', 'b', 'c', 'd'];
244
+ * const values = ['a', 'b', 'c', 'd'] as const;
245
245
  *
246
246
  * const withoutLastTwo = Arr.skipLast(values, 2);
247
247
  *
@@ -43,7 +43,7 @@ describe('Arr slicing', () => {
43
43
 
44
44
  describe(butLast, () => {
45
45
  test('readonly number[] type', () => {
46
- const xs: readonly number[] = [1, 2, 3];
46
+ const xs: readonly number[] = [1, 2, 3] as const;
47
47
 
48
48
  const bl = butLast(xs);
49
49
 
@@ -97,7 +97,7 @@ describe('Arr slicing', () => {
97
97
  }
98
98
 
99
99
  {
100
- const xs: readonly number[] = [1, 2, 3];
100
+ const xs: readonly number[] = [1, 2, 3] as const;
101
101
 
102
102
  const t = take(xs, 2);
103
103
 
@@ -131,7 +131,7 @@ describe('Arr slicing', () => {
131
131
  }
132
132
 
133
133
  {
134
- const xs: readonly number[] = [1, 2, 3];
134
+ const xs: readonly number[] = [1, 2, 3] as const;
135
135
 
136
136
  const t = takeLast(xs, 2);
137
137
 
@@ -165,7 +165,7 @@ describe('Arr slicing', () => {
165
165
  }
166
166
 
167
167
  {
168
- const xs: readonly number[] = [1, 2, 3];
168
+ const xs: readonly number[] = [1, 2, 3] as const;
169
169
 
170
170
  const t = skip(xs, 2);
171
171
 
@@ -199,7 +199,7 @@ describe('Arr slicing', () => {
199
199
  }
200
200
 
201
201
  {
202
- const xs: readonly number[] = [1, 2, 3];
202
+ const xs: readonly number[] = [1, 2, 3] as const;
203
203
 
204
204
  const t = skipLast(xs, 2);
205
205
 
@@ -679,7 +679,7 @@ export const concat = <
679
679
  >(
680
680
  array1: Ar1,
681
681
  array2: Ar2,
682
- ): readonly [...Ar1, ...Ar2] => [...array1, ...array2];
682
+ ): readonly [...Ar1, ...Ar2] => [...array1, ...array2] as const;
683
683
 
684
684
  /**
685
685
  * Groups elements by a key derived from each element.