@rimbu/base 2.0.1 → 2.0.3

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 (44) hide show
  1. package/README.md +183 -26
  2. package/dist/bun/arr.mts +184 -19
  3. package/dist/bun/entry.mts +14 -2
  4. package/dist/bun/index.mts +10 -0
  5. package/dist/bun/rimbu-error.mts +25 -0
  6. package/dist/bun/token.mts +7 -0
  7. package/dist/cjs/arr.cjs +209 -44
  8. package/dist/cjs/arr.cjs.map +1 -1
  9. package/dist/cjs/arr.d.cts +184 -0
  10. package/dist/cjs/entry.cjs +16 -5
  11. package/dist/cjs/entry.cjs.map +1 -1
  12. package/dist/cjs/entry.d.cts +14 -0
  13. package/dist/cjs/index.cjs +10 -0
  14. package/dist/cjs/index.cjs.map +1 -1
  15. package/dist/cjs/index.d.cts +9 -0
  16. package/dist/cjs/plain-object.cjs +2 -3
  17. package/dist/cjs/plain-object.cjs.map +1 -1
  18. package/dist/cjs/rimbu-error.cjs +30 -5
  19. package/dist/cjs/rimbu-error.cjs.map +1 -1
  20. package/dist/cjs/rimbu-error.d.cts +25 -0
  21. package/dist/cjs/token.cjs +4 -0
  22. package/dist/cjs/token.cjs.map +1 -1
  23. package/dist/cjs/token.d.cts +7 -0
  24. package/dist/esm/arr.d.mts +184 -0
  25. package/dist/esm/arr.mjs +184 -19
  26. package/dist/esm/arr.mjs.map +1 -1
  27. package/dist/esm/entry.d.mts +14 -0
  28. package/dist/esm/entry.mjs +14 -2
  29. package/dist/esm/entry.mjs.map +1 -1
  30. package/dist/esm/index.d.mts +9 -0
  31. package/dist/esm/index.mjs +10 -0
  32. package/dist/esm/index.mjs.map +1 -1
  33. package/dist/esm/rimbu-error.d.mts +25 -0
  34. package/dist/esm/rimbu-error.mjs +25 -0
  35. package/dist/esm/rimbu-error.mjs.map +1 -1
  36. package/dist/esm/token.d.mts +7 -0
  37. package/dist/esm/token.mjs +4 -0
  38. package/dist/esm/token.mjs.map +1 -1
  39. package/package.json +5 -5
  40. package/src/arr.mts +184 -19
  41. package/src/entry.mts +14 -2
  42. package/src/index.mts +10 -0
  43. package/src/rimbu-error.mts +25 -0
  44. package/src/token.mts +7 -0
@@ -1,33 +1,217 @@
1
1
  import { TraverseState, Update, type ArrayNonEmpty } from '@rimbu/common';
2
+ /**
3
+ * Internal helper that appends a value using the modern immutable `toSpliced` API.
4
+ * @internal
5
+ * @typeparam T - the array element type
6
+ * @param array - the source array (not mutated)
7
+ * @param value - the value to append
8
+ * @returns a new non-empty array with the value at the end
9
+ */
2
10
  export declare function _appendNew<T>(array: readonly T[], value: T): ArrayNonEmpty<T>;
11
+ /**
12
+ * Internal helper that appends a value by cloning and pushing (legacy fallback).
13
+ * @internal
14
+ * @typeparam T - the array element type
15
+ * @param array - the source array (not mutated)
16
+ * @param value - the value to append
17
+ * @returns a new non-empty array with the value at the end
18
+ */
3
19
  export declare function _appendOld<T>(array: readonly T[], value: T): ArrayNonEmpty<T>;
20
+ /**
21
+ * Returns a copy of the array with the given value appended.
22
+ * Chooses an implementation depending on environment capabilities.
23
+ * @typeparam T - the array element type
24
+ * @param array - the source array (not mutated)
25
+ * @param value - the value to append
26
+ * @returns a new array with the value at the end
27
+ */
4
28
  export declare const append: typeof _appendNew;
29
+ /**
30
+ * Returns the concatenation of two arrays, reusing an input array when the other is empty.
31
+ * @typeparam T - the array element type
32
+ * @param first - the first array
33
+ * @param second - the second array
34
+ * @returns a new array containing all elements of both arrays (or one of the originals if the other is empty)
35
+ */
5
36
  export declare function concat<T>(first: readonly T[], second: readonly T[]): readonly T[];
37
+ /**
38
+ * Internal helper to create a reversed copy using modern `toReversed` with optional slicing.
39
+ * @internal
40
+ */
6
41
  export declare function _reverseNew<T>(array: readonly T[], start?: number, end?: number): T[];
42
+ /**
43
+ * Internal helper to create a reversed copy using manual iteration (legacy fallback).
44
+ * @internal
45
+ */
7
46
  export declare function _reverseOld<T>(array: readonly T[], start?: number, end?: number): T[];
47
+ /**
48
+ * Returns a copy of the array (or a slice) with elements in reversed order.
49
+ * @typeparam T - array element type
50
+ * @param array - the source array
51
+ * @param start - optional start index (inclusive)
52
+ * @param end - optional end index (inclusive)
53
+ */
8
54
  export declare const reverse: typeof _reverseNew;
55
+ /**
56
+ * Performs the given function for each element of the array, optionally in reverse order.
57
+ * Halting is supported through the provided `TraverseState`.
58
+ * @typeparam T - element type
59
+ * @param array - the source array
60
+ * @param f - callback receiving (value, sequential index, halt)
61
+ * @param state - traversal state (created if omitted)
62
+ * @param reversed - whether to traverse in reverse order
63
+ */
9
64
  export declare function forEach<T>(array: readonly T[], f: (value: T, index: number, halt: () => void) => void, state?: TraverseState, reversed?: boolean): void;
65
+ /**
66
+ * Returns a copy of the array where the given function is applied to each element.
67
+ * Supports an index offset useful for composed traversals.
68
+ * @typeparam T - source element type
69
+ * @typeparam R - result element type
70
+ * @param array - the source array
71
+ * @param f - the mapping function
72
+ * @param indexOffset - optional start index value passed to `f`
73
+ */
10
74
  export declare function map<T, R>(array: readonly T[], f: (value: T, index: number) => R, indexOffset?: number): R[];
75
+ /**
76
+ * Returns a copy of the array where the given function is applied to each element in reverse order.
77
+ * @typeparam T - source element type
78
+ * @typeparam R - result element type
79
+ * @param array - the source array
80
+ * @param f - the mapping function
81
+ * @param indexOffset - optional index offset passed to `f`
82
+ */
11
83
  export declare function reverseMap<T, R>(array: readonly T[], f: (value: T, index: number) => R, indexOffset?: number): R[];
84
+ /**
85
+ * Internal helper to prepend a value using `toSpliced`.
86
+ * @internal
87
+ */
12
88
  export declare function _prependNew<T>(array: readonly T[], value: T): ArrayNonEmpty<T>;
89
+ /**
90
+ * Internal helper to prepend a value using legacy cloning.
91
+ * @internal
92
+ */
13
93
  export declare function _prependOld<T>(array: readonly T[], value: T): ArrayNonEmpty<T>;
94
+ /**
95
+ * Returns a copy of the array with the given value inserted at the start.
96
+ * @typeparam T - element type
97
+ * @param array - the source array
98
+ * @param value - value to insert at index 0
99
+ */
14
100
  export declare const prepend: typeof _prependNew;
101
+ /**
102
+ * Internal helper to obtain the last element using modern `at`.
103
+ * @internal
104
+ */
15
105
  export declare function _lastNew<T>(arr: readonly T[]): T;
106
+ /**
107
+ * Internal helper to obtain the last element using index arithmetic.
108
+ * @internal
109
+ */
16
110
  export declare function _lastOld<T>(arr: readonly T[]): T;
111
+ /**
112
+ * Returns the last element of the array.
113
+ * @typeparam T - element type
114
+ * @param arr - the array
115
+ */
17
116
  export declare const last: typeof _lastNew;
117
+ /**
118
+ * Internal helper implementing an immutable index update via `with`.
119
+ * @internal
120
+ */
18
121
  export declare function _updateNew<T>(arr: readonly T[], index: number, updater: Update<T>): readonly T[];
122
+ /**
123
+ * Internal helper implementing an immutable index update via cloning.
124
+ * @internal
125
+ */
19
126
  export declare function _updateOld<T>(arr: readonly T[], index: number, updater: Update<T>): readonly T[];
127
+ /**
128
+ * Returns a copy of the array where the element at the given index is replaced using the provided updater.
129
+ * If the result value is identical (by `Object.is`) the original array is returned.
130
+ * @typeparam T - element type
131
+ * @param arr - the source array
132
+ * @param index - the index to update
133
+ * @param updater - value or function update description
134
+ */
20
135
  export declare const update: typeof _updateNew;
136
+ /**
137
+ * Internal helper applying a modifier function via `with`.
138
+ * @internal
139
+ */
21
140
  export declare function _modNew<T>(arr: readonly T[], index: number, f: (value: T) => T): readonly T[];
141
+ /**
142
+ * Internal helper applying a modifier function via cloning.
143
+ * @internal
144
+ */
22
145
  export declare function _modOld<T>(arr: readonly T[], index: number, f: (value: T) => T): readonly T[];
146
+ /**
147
+ * Returns a copy of the array where the element at the given index is transformed by a modifier function.
148
+ * If the result value is identical (by `Object.is`) the original array is returned.
149
+ * @typeparam T - element type
150
+ * @param arr - the source array
151
+ * @param index - the index to modify
152
+ * @param f - modifier function receiving the current value
153
+ */
23
154
  export declare const mod: typeof _modNew;
155
+ /**
156
+ * Internal helper for inserting a value using `toSpliced`.
157
+ * @internal
158
+ */
24
159
  export declare function _insertNew<T>(arr: readonly T[], index: number, value: T): T[];
160
+ /**
161
+ * Internal helper for inserting a value using legacy `splice` on a clone.
162
+ * @internal
163
+ */
25
164
  export declare function _insertOld<T>(arr: readonly T[], index: number, value: T): T[];
165
+ /**
166
+ * Returns a copy of the array where at the given index the provided value is inserted.
167
+ * @typeparam T - element type
168
+ * @param arr - the source array
169
+ * @param index - insertion index
170
+ * @param value - value to insert
171
+ */
26
172
  export declare const insert: typeof _insertNew;
173
+ /**
174
+ * Returns a copy of the array without its first element.
175
+ * @typeparam T - element type
176
+ * @param arr - the source array
177
+ */
27
178
  export declare function tail<T>(arr: readonly T[]): T[];
179
+ /**
180
+ * Returns a copy of the array without its last element.
181
+ * @typeparam T - element type
182
+ * @param arr - the source array
183
+ */
28
184
  export declare function init<T>(arr: readonly T[]): T[];
185
+ /**
186
+ * Internal helper providing an immutable `splice` using `toSpliced`.
187
+ * @internal
188
+ */
29
189
  export declare function _spliceNew<T>(arr: readonly T[], start: number, deleteCount: number, ...items: T[]): T[];
190
+ /**
191
+ * Internal helper providing an immutable `splice` via cloning.
192
+ * @internal
193
+ */
30
194
  export declare function _spliceOld<T>(arr: readonly T[], start: number, deleteCount: number, ...items: T[]): T[];
195
+ /**
196
+ * Immutable version of the array `.splice` command, always returning a new array.
197
+ * @typeparam T - element type
198
+ * @param arr - the source array
199
+ * @param start - start index
200
+ * @param deleteCount - number of elements to delete
201
+ * @param items - optional items to insert
202
+ */
31
203
  export declare const splice: typeof _spliceNew;
204
+ /**
205
+ * Returns a copy of a (potentially) sparse array preserving sparsity (skips holes).
206
+ * @typeparam T - element type
207
+ * @param arr - the source sparse array
208
+ */
32
209
  export declare function copySparse<T>(arr: readonly T[]): T[];
210
+ /**
211
+ * Returns a copy of a sparse array applying the given function to each present element, preserving holes.
212
+ * @typeparam T - source element type
213
+ * @typeparam T2 - result element type
214
+ * @param arr - the source sparse array
215
+ * @param f - mapping function
216
+ */
33
217
  export declare function mapSparse<T, T2>(arr: readonly T[], f: (value: T, index: number) => T2): T2[];
package/dist/esm/arr.mjs CHANGED
@@ -1,15 +1,44 @@
1
1
  import { TraverseState, Update } from '@rimbu/common';
2
+ /**
3
+ * Internal helper that appends a value using the modern immutable `toSpliced` API.
4
+ * @internal
5
+ * @typeparam T - the array element type
6
+ * @param array - the source array (not mutated)
7
+ * @param value - the value to append
8
+ * @returns a new non-empty array with the value at the end
9
+ */
2
10
  export function _appendNew(array, value) {
3
11
  return array.toSpliced(array.length, 0, value);
4
12
  }
13
+ /**
14
+ * Internal helper that appends a value by cloning and pushing (legacy fallback).
15
+ * @internal
16
+ * @typeparam T - the array element type
17
+ * @param array - the source array (not mutated)
18
+ * @param value - the value to append
19
+ * @returns a new non-empty array with the value at the end
20
+ */
5
21
  export function _appendOld(array, value) {
6
22
  const clone = array.slice();
7
23
  clone.push(value);
8
24
  return clone;
9
25
  }
10
- // Returns a copy of the array with the given value appended
26
+ /**
27
+ * Returns a copy of the array with the given value appended.
28
+ * Chooses an implementation depending on environment capabilities.
29
+ * @typeparam T - the array element type
30
+ * @param array - the source array (not mutated)
31
+ * @param value - the value to append
32
+ * @returns a new array with the value at the end
33
+ */
11
34
  export const append = `toSpliced` in Array.prototype ? _appendNew : _appendOld;
12
- // Returns the concatenation of the two arrays, potentially reusing the input array if one of the arrays is empty
35
+ /**
36
+ * Returns the concatenation of two arrays, reusing an input array when the other is empty.
37
+ * @typeparam T - the array element type
38
+ * @param first - the first array
39
+ * @param second - the second array
40
+ * @returns a new array containing all elements of both arrays (or one of the originals if the other is empty)
41
+ */
13
42
  export function concat(first, second) {
14
43
  if (first.length === 0)
15
44
  return second;
@@ -17,12 +46,20 @@ export function concat(first, second) {
17
46
  return first;
18
47
  return first.concat(second);
19
48
  }
49
+ /**
50
+ * Internal helper to create a reversed copy using modern `toReversed` with optional slicing.
51
+ * @internal
52
+ */
20
53
  export function _reverseNew(array, start, end) {
21
54
  const source = undefined !== start || undefined !== end
22
55
  ? array.slice(start ?? 0, (end ?? array.length - 1) + 1)
23
56
  : array;
24
57
  return source.toReversed();
25
58
  }
59
+ /**
60
+ * Internal helper to create a reversed copy using manual iteration (legacy fallback).
61
+ * @internal
62
+ */
26
63
  export function _reverseOld(array, start, end) {
27
64
  const _start = start ?? 0;
28
65
  const _end = end ?? array.length - 1;
@@ -34,9 +71,23 @@ export function _reverseOld(array, start, end) {
34
71
  res[resIndex--] = array[arrayIndex];
35
72
  return res;
36
73
  }
37
- // Returns an copy of the array between the start and end indices, with the elements in reversed order.
74
+ /**
75
+ * Returns a copy of the array (or a slice) with elements in reversed order.
76
+ * @typeparam T - array element type
77
+ * @param array - the source array
78
+ * @param start - optional start index (inclusive)
79
+ * @param end - optional end index (inclusive)
80
+ */
38
81
  export const reverse = 'toReversed' in Array.prototype ? _reverseNew : _reverseOld;
39
- // Performs given function on each element of the array, in reverse order if 'reversed' is true.
82
+ /**
83
+ * Performs the given function for each element of the array, optionally in reverse order.
84
+ * Halting is supported through the provided `TraverseState`.
85
+ * @typeparam T - element type
86
+ * @param array - the source array
87
+ * @param f - callback receiving (value, sequential index, halt)
88
+ * @param state - traversal state (created if omitted)
89
+ * @param reversed - whether to traverse in reverse order
90
+ */
40
91
  export function forEach(array, f, state = TraverseState(), reversed = false) {
41
92
  if (state.halted)
42
93
  return;
@@ -55,7 +106,15 @@ export function forEach(array, f, state = TraverseState(), reversed = false) {
55
106
  }
56
107
  }
57
108
  }
58
- // Returns a copy of the array where given function is applied to each element
109
+ /**
110
+ * Returns a copy of the array where the given function is applied to each element.
111
+ * Supports an index offset useful for composed traversals.
112
+ * @typeparam T - source element type
113
+ * @typeparam R - result element type
114
+ * @param array - the source array
115
+ * @param f - the mapping function
116
+ * @param indexOffset - optional start index value passed to `f`
117
+ */
59
118
  export function map(array, f, indexOffset = 0) {
60
119
  if (indexOffset === 0) {
61
120
  // without offset, can use standard array map
@@ -70,7 +129,14 @@ export function map(array, f, indexOffset = 0) {
70
129
  }
71
130
  return result;
72
131
  }
73
- // Returns a copy of the array where given functio is applied to each element in reverse order
132
+ /**
133
+ * Returns a copy of the array where the given function is applied to each element in reverse order.
134
+ * @typeparam T - source element type
135
+ * @typeparam R - result element type
136
+ * @param array - the source array
137
+ * @param f - the mapping function
138
+ * @param indexOffset - optional index offset passed to `f`
139
+ */
74
140
  export function reverseMap(array, f, indexOffset = 0) {
75
141
  const result = [];
76
142
  let index = indexOffset;
@@ -80,24 +146,53 @@ export function reverseMap(array, f, indexOffset = 0) {
80
146
  result[resultIndex++] = f(array[arrayIndex], index++);
81
147
  return result;
82
148
  }
149
+ /**
150
+ * Internal helper to prepend a value using `toSpliced`.
151
+ * @internal
152
+ */
83
153
  export function _prependNew(array, value) {
84
154
  return array.toSpliced(0, 0, value);
85
155
  }
156
+ /**
157
+ * Internal helper to prepend a value using legacy cloning.
158
+ * @internal
159
+ */
86
160
  export function _prependOld(array, value) {
87
161
  const clone = array.slice();
88
162
  clone.unshift(value);
89
163
  return clone;
90
164
  }
91
- // Returns a copy of the given array with the given value added at the start
165
+ /**
166
+ * Returns a copy of the array with the given value inserted at the start.
167
+ * @typeparam T - element type
168
+ * @param array - the source array
169
+ * @param value - value to insert at index 0
170
+ */
92
171
  export const prepend = `toSpliced` in Array.prototype ? _prependNew : _prependOld;
172
+ /**
173
+ * Internal helper to obtain the last element using modern `at`.
174
+ * @internal
175
+ */
93
176
  export function _lastNew(arr) {
94
177
  return arr.at(-1);
95
178
  }
179
+ /**
180
+ * Internal helper to obtain the last element using index arithmetic.
181
+ * @internal
182
+ */
96
183
  export function _lastOld(arr) {
97
184
  return arr[arr.length - 1];
98
185
  }
99
- // Returns the last element of the array
186
+ /**
187
+ * Returns the last element of the array.
188
+ * @typeparam T - element type
189
+ * @param arr - the array
190
+ */
100
191
  export const last = `at` in Array.prototype ? _lastNew : _lastOld;
192
+ /**
193
+ * Internal helper implementing an immutable index update via `with`.
194
+ * @internal
195
+ */
101
196
  export function _updateNew(arr, index, updater) {
102
197
  if (index < 0 || index >= arr.length) {
103
198
  return arr;
@@ -109,6 +204,10 @@ export function _updateNew(arr, index, updater) {
109
204
  }
110
205
  return arr.with(index, newValue);
111
206
  }
207
+ /**
208
+ * Internal helper implementing an immutable index update via cloning.
209
+ * @internal
210
+ */
112
211
  export function _updateOld(arr, index, updater) {
113
212
  if (index < 0 || index >= arr.length) {
114
213
  return arr;
@@ -122,9 +221,19 @@ export function _updateOld(arr, index, updater) {
122
221
  newArr[index] = newValue;
123
222
  return newArr;
124
223
  }
125
- // Returns a copy of the array where the element at given index is replaced by the given updater.
126
- // If the new element is the same as the old element, the original array is returned
224
+ /**
225
+ * Returns a copy of the array where the element at the given index is replaced using the provided updater.
226
+ * If the result value is identical (by `Object.is`) the original array is returned.
227
+ * @typeparam T - element type
228
+ * @param arr - the source array
229
+ * @param index - the index to update
230
+ * @param updater - value or function update description
231
+ */
127
232
  export const update = `with` in Array.prototype ? _updateNew : _updateOld;
233
+ /**
234
+ * Internal helper applying a modifier function via `with`.
235
+ * @internal
236
+ */
128
237
  export function _modNew(arr, index, f) {
129
238
  if (index < 0 || index >= arr.length) {
130
239
  return arr;
@@ -136,6 +245,10 @@ export function _modNew(arr, index, f) {
136
245
  }
137
246
  return arr.with(index, newValue);
138
247
  }
248
+ /**
249
+ * Internal helper applying a modifier function via cloning.
250
+ * @internal
251
+ */
139
252
  export function _modOld(arr, index, f) {
140
253
  if (index < 0 || index >= arr.length) {
141
254
  return arr;
@@ -149,38 +262,85 @@ export function _modOld(arr, index, f) {
149
262
  newArr[index] = newValue;
150
263
  return newArr;
151
264
  }
152
- // Returns a copy of the array where the element at given index is replaced by applying given function.
153
- // If the new element is the same as the old element, the original array is returned
265
+ /**
266
+ * Returns a copy of the array where the element at the given index is transformed by a modifier function.
267
+ * If the result value is identical (by `Object.is`) the original array is returned.
268
+ * @typeparam T - element type
269
+ * @param arr - the source array
270
+ * @param index - the index to modify
271
+ * @param f - modifier function receiving the current value
272
+ */
154
273
  export const mod = `with` in Array.prototype ? _modNew : _modOld;
274
+ /**
275
+ * Internal helper for inserting a value using `toSpliced`.
276
+ * @internal
277
+ */
155
278
  export function _insertNew(arr, index, value) {
156
279
  return arr.toSpliced(index, 0, value);
157
280
  }
281
+ /**
282
+ * Internal helper for inserting a value using legacy `splice` on a clone.
283
+ * @internal
284
+ */
158
285
  export function _insertOld(arr, index, value) {
159
286
  const clone = arr.slice();
160
287
  clone.splice(index, 0, value);
161
288
  return clone;
162
289
  }
163
- // Returns a copy of the array where at given index the given value is inserted
290
+ /**
291
+ * Returns a copy of the array where at the given index the provided value is inserted.
292
+ * @typeparam T - element type
293
+ * @param arr - the source array
294
+ * @param index - insertion index
295
+ * @param value - value to insert
296
+ */
164
297
  export const insert = `toSpliced` in Array.prototype ? _insertNew : _insertOld;
165
- // Returns a copy of the array, without its first element
298
+ /**
299
+ * Returns a copy of the array without its first element.
300
+ * @typeparam T - element type
301
+ * @param arr - the source array
302
+ */
166
303
  export function tail(arr) {
167
304
  return arr.slice(1);
168
305
  }
169
- // Returns a copy of the array, without its last element
306
+ /**
307
+ * Returns a copy of the array without its last element.
308
+ * @typeparam T - element type
309
+ * @param arr - the source array
310
+ */
170
311
  export function init(arr) {
171
312
  return arr.slice(0, arr.length - 1);
172
313
  }
314
+ /**
315
+ * Internal helper providing an immutable `splice` using `toSpliced`.
316
+ * @internal
317
+ */
173
318
  export function _spliceNew(arr, start, deleteCount, ...items) {
174
319
  return arr.toSpliced(start, deleteCount, ...items);
175
320
  }
321
+ /**
322
+ * Internal helper providing an immutable `splice` via cloning.
323
+ * @internal
324
+ */
176
325
  export function _spliceOld(arr, start, deleteCount, ...items) {
177
326
  const clone = arr.slice();
178
327
  clone.splice(start, deleteCount, ...items);
179
328
  return clone;
180
329
  }
181
- // Immutable version of the array .splice command, always returns a new array
330
+ /**
331
+ * Immutable version of the array `.splice` command, always returning a new array.
332
+ * @typeparam T - element type
333
+ * @param arr - the source array
334
+ * @param start - start index
335
+ * @param deleteCount - number of elements to delete
336
+ * @param items - optional items to insert
337
+ */
182
338
  export const splice = `toSpliced` in Array.prototype ? _spliceNew : _spliceOld;
183
- // Returns a copy of the array, where its 'sparse' property is kept (sparse = not all indices have a value)
339
+ /**
340
+ * Returns a copy of a (potentially) sparse array preserving sparsity (skips holes).
341
+ * @typeparam T - element type
342
+ * @param arr - the source sparse array
343
+ */
184
344
  export function copySparse(arr) {
185
345
  const clone = [];
186
346
  for (const key in arr) {
@@ -188,8 +348,13 @@ export function copySparse(arr) {
188
348
  }
189
349
  return clone;
190
350
  }
191
- // Returns a copy of the array with given function applied to each element, where its 'sparse' property is kept
192
- // (sparse = not all indices have a value)
351
+ /**
352
+ * Returns a copy of a sparse array applying the given function to each present element, preserving holes.
353
+ * @typeparam T - source element type
354
+ * @typeparam T2 - result element type
355
+ * @param arr - the source sparse array
356
+ * @param f - mapping function
357
+ */
193
358
  export function mapSparse(arr, f) {
194
359
  const result = Array(arr.length);
195
360
  for (const key in arr) {
@@ -1 +1 @@
1
- {"version":3,"file":"arr.mjs","sourceRoot":"","sources":["../../src/arr.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAsB,MAAM,eAAe,CAAC;AAE1E,MAAM,UAAU,UAAU,CAAI,KAAmB,EAAE,KAAQ;IACzD,OAAO,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,CAAqB,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,UAAU,CAAI,KAAmB,EAAE,KAAQ;IACzD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IAC5B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,OAAO,KAAyB,CAAC;AACnC,CAAC;AAED,4DAA4D;AAC5D,MAAM,CAAC,MAAM,MAAM,GAAG,WAAW,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC;AAE/E,iHAAiH;AACjH,MAAM,UAAU,MAAM,CACpB,KAAmB,EACnB,MAAoB;IAEpB,IAAI,KAAK,CAAC,M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AAU;IAEb,OAAO,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,GAAiB,EACjB,KAAa,EACb,WAAmB,EACnB,GAAG,KAAU;IAEb,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC;IAC1B,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,CAAC;IAC3C,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,WAAW,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC;AAE/E;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAI,GAAiB;IAC7C,MAAM,KAAK,GAAQ,EAAE,CAAC;IACtB,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,KAAK,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CACvB,GAAiB,EACjB,CAAkC;IAElC,MAAM,MAAM,GAAS,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAEvC,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAU,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,2 +1,16 @@
1
+ /**
2
+ * Returns the first element of a 2-tuple.
3
+ * @typeparam K - the first element type
4
+ * @typeparam V - the second element type
5
+ * @param entry - the tuple
6
+ * @returns the first element
7
+ */
1
8
  export declare function first<K, V>(entry: readonly [K, V]): K;
9
+ /**
10
+ * Returns the second element of a 2-tuple.
11
+ * @typeparam K - the first element type
12
+ * @typeparam V - the second element type
13
+ * @param entry - the tuple
14
+ * @returns the second element
15
+ */
2
16
  export declare function second<K, V>(entry: readonly [K, V]): V;
@@ -1,8 +1,20 @@
1
- // Returns the first element of a 2-Tuple
1
+ /**
2
+ * Returns the first element of a 2-tuple.
3
+ * @typeparam K - the first element type
4
+ * @typeparam V - the second element type
5
+ * @param entry - the tuple
6
+ * @returns the first element
7
+ */
2
8
  export function first(entry) {
3
9
  return entry[0];
4
10
  }
5
- // Returns the second element of a 2-Tuple
11
+ /**
12
+ * Returns the second element of a 2-tuple.
13
+ * @typeparam K - the first element type
14
+ * @typeparam V - the second element type
15
+ * @param entry - the tuple
16
+ * @returns the second element
17
+ */
6
18
  export function second(entry) {
7
19
  return entry[1];
8
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"entry.mjs","sourceRoot":"","sources":["../../src/entry.mts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,MAAM,UAAU,KAAK,CAAO,KAAsB;IAChD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,MAAM,CAAO,KAAsB;IACjD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
1
+ {"version":3,"file":"entry.mjs","sourceRoot":"","sources":["../../src/entry.mts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAO,KAAsB;IAChD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,MAAM,CAAO,KAAsB;IACjD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
@@ -1,3 +1,12 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * The `@rimbu/base` package provides foundational immutable array utilities, tuple helpers,
5
+ * plain‑object type predicates and structured error types that power all other Rimbu collections.<br/>
6
+ * Use it directly when you need low‑level, performance‑aware primitives for persistent data
7
+ * structures without pulling in the higher‑level collection packages.<br/>
8
+ * See the Rimbu docs and API reference for more information.
9
+ */
1
10
  export * as Arr from './arr.mjs';
2
11
  export * as Entry from './entry.mjs';
3
12
  export * as RimbuError from './rimbu-error.mjs';
@@ -1,6 +1,16 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * The `@rimbu/base` package provides foundational immutable array utilities, tuple helpers,
5
+ * plain‑object type predicates and structured error types that power all other Rimbu collections.<br/>
6
+ * Use it directly when you need low‑level, performance‑aware primitives for persistent data
7
+ * structures without pulling in the higher‑level collection packages.<br/>
8
+ * See the Rimbu docs and API reference for more information.
9
+ */
1
10
  export * as Arr from './arr.mjs';
2
11
  export * as Entry from './entry.mjs';
3
12
  export * as RimbuError from './rimbu-error.mjs';
4
13
  export * from './plain-object.mjs';
14
+ // Internal exports (may change without notice)
5
15
  export * from './internal.mjs';
6
16
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/index.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,cAAc,oBAAoB,CAAC;AAEnC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/index.mts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,cAAc,oBAAoB,CAAC;AAEnC,+CAA+C;AAC/C,cAAc,gBAAgB,CAAC"}