@rimbu/base 2.0.2 → 2.0.4

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 (42) hide show
  1. package/README.md +165 -35
  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 +184 -19
  8. package/dist/cjs/arr.cjs.map +1 -1
  9. package/dist/cjs/arr.d.cts +184 -0
  10. package/dist/cjs/entry.cjs +14 -2
  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/rimbu-error.cjs +25 -0
  17. package/dist/cjs/rimbu-error.cjs.map +1 -1
  18. package/dist/cjs/rimbu-error.d.cts +25 -0
  19. package/dist/cjs/token.cjs +4 -0
  20. package/dist/cjs/token.cjs.map +1 -1
  21. package/dist/cjs/token.d.cts +7 -0
  22. package/dist/esm/arr.d.mts +184 -0
  23. package/dist/esm/arr.mjs +184 -19
  24. package/dist/esm/arr.mjs.map +1 -1
  25. package/dist/esm/entry.d.mts +14 -0
  26. package/dist/esm/entry.mjs +14 -2
  27. package/dist/esm/entry.mjs.map +1 -1
  28. package/dist/esm/index.d.mts +9 -0
  29. package/dist/esm/index.mjs +10 -0
  30. package/dist/esm/index.mjs.map +1 -1
  31. package/dist/esm/rimbu-error.d.mts +25 -0
  32. package/dist/esm/rimbu-error.mjs +25 -0
  33. package/dist/esm/rimbu-error.mjs.map +1 -1
  34. package/dist/esm/token.d.mts +7 -0
  35. package/dist/esm/token.mjs +4 -0
  36. package/dist/esm/token.mjs.map +1 -1
  37. package/package.json +4 -9
  38. package/src/arr.mts +184 -19
  39. package/src/entry.mts +14 -2
  40. package/src/index.mts +10 -0
  41. package/src/rimbu-error.mts +25 -0
  42. package/src/token.mts +7 -0
@@ -2,11 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.first = first;
4
4
  exports.second = second;
5
- // Returns the first element of a 2-Tuple
5
+ /**
6
+ * Returns the first element of a 2-tuple.
7
+ * @typeparam K - the first element type
8
+ * @typeparam V - the second element type
9
+ * @param entry - the tuple
10
+ * @returns the first element
11
+ */
6
12
  function first(entry) {
7
13
  return entry[0];
8
14
  }
9
- // Returns the second element of a 2-Tuple
15
+ /**
16
+ * Returns the second element of a 2-tuple.
17
+ * @typeparam K - the first element type
18
+ * @typeparam V - the second element type
19
+ * @param entry - the tuple
20
+ * @returns the second element
21
+ */
10
22
  function second(entry) {
11
23
  return entry[1];
12
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"entry.cjs","sourceRoot":"","sources":["../../_cjs_prepare/entry.cts"],"names":[],"mappings":";;AACA,sBAEC;AAGD,wBAEC;AARD,yCAAyC;AACzC,SAAgB,KAAK,CAAO,KAAsB;IAChD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,0CAA0C;AAC1C,SAAgB,MAAM,CAAO,KAAsB;IACjD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
1
+ {"version":3,"file":"entry.cjs","sourceRoot":"","sources":["../../_cjs_prepare/entry.cts"],"names":[],"mappings":";;AAOA,sBAEC;AASD,wBAEC;AApBD;;;;;;GAMG;AACH,SAAgB,KAAK,CAAO,KAAsB;IAChD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,MAAM,CAAO,KAAsB;IACjD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,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;
@@ -2,9 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RimbuError = exports.Entry = exports.Arr = void 0;
4
4
  var tslib_1 = require("tslib");
5
+ /**
6
+ * @packageDocumentation
7
+ *
8
+ * The `@rimbu/base` package provides foundational immutable array utilities, tuple helpers,
9
+ * plain‑object type predicates and structured error types that power all other Rimbu collections.<br/>
10
+ * Use it directly when you need low‑level, performance‑aware primitives for persistent data
11
+ * structures without pulling in the higher‑level collection packages.<br/>
12
+ * See the Rimbu docs and API reference for more information.
13
+ */
5
14
  exports.Arr = tslib_1.__importStar(require("./arr.cjs"));
6
15
  exports.Entry = tslib_1.__importStar(require("./entry.cjs"));
7
16
  exports.RimbuError = tslib_1.__importStar(require("./rimbu-error.cjs"));
8
17
  tslib_1.__exportStar(require("./plain-object.cjs"), exports);
18
+ // Internal exports (may change without notice)
9
19
  tslib_1.__exportStar(require("./internal.cjs"), exports);
10
20
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../_cjs_prepare/index.cts"],"names":[],"mappings":";;;;AAAA,yDAAiC;AACjC,6DAAqC;AACrC,wEAAgD;AAChD,6DAAmC;AAEnC,yDAA+B"}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../_cjs_prepare/index.cts"],"names":[],"mappings":";;;;AAAA;;;;;;;;GAQG;AACH,yDAAiC;AACjC,6DAAqC;AACrC,wEAAgD;AAChD,6DAAmC;AAEnC,+CAA+C;AAC/C,yDAA+B"}
@@ -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.cjs';
2
11
  export * as Entry from './entry.cjs';
3
12
  export * as RimbuError from './rimbu-error.cjs';
@@ -7,6 +7,9 @@ exports.throwInvalidStateError = throwInvalidStateError;
7
7
  exports.throwInvalidUsageError = throwInvalidUsageError;
8
8
  var tslib_1 = require("tslib");
9
9
  var common_1 = require("@rimbu/common");
10
+ /**
11
+ * Error thrown when an operation assumes a collection is non-empty but it is empty.
12
+ */
10
13
  var EmptyCollectionAssumedNonEmptyError = /** @class */ (function (_super) {
11
14
  tslib_1.__extends(EmptyCollectionAssumedNonEmptyError, _super);
12
15
  function EmptyCollectionAssumedNonEmptyError() {
@@ -15,6 +18,9 @@ var EmptyCollectionAssumedNonEmptyError = /** @class */ (function (_super) {
15
18
  return EmptyCollectionAssumedNonEmptyError;
16
19
  }(common_1.ErrBase.CustomError));
17
20
  exports.EmptyCollectionAssumedNonEmptyError = EmptyCollectionAssumedNonEmptyError;
21
+ /**
22
+ * Error thrown when a builder is modified while it is being iterated.
23
+ */
18
24
  var ModifiedBuilderWhileLoopingOverItError = /** @class */ (function (_super) {
19
25
  tslib_1.__extends(ModifiedBuilderWhileLoopingOverItError, _super);
20
26
  function ModifiedBuilderWhileLoopingOverItError() {
@@ -23,6 +29,9 @@ var ModifiedBuilderWhileLoopingOverItError = /** @class */ (function (_super) {
23
29
  return ModifiedBuilderWhileLoopingOverItError;
24
30
  }(common_1.ErrBase.CustomError));
25
31
  exports.ModifiedBuilderWhileLoopingOverItError = ModifiedBuilderWhileLoopingOverItError;
32
+ /**
33
+ * Error indicating an unexpected internal state. Users are encouraged to file an issue.
34
+ */
26
35
  var InvalidStateError = /** @class */ (function (_super) {
27
36
  tslib_1.__extends(InvalidStateError, _super);
28
37
  function InvalidStateError() {
@@ -31,6 +40,9 @@ var InvalidStateError = /** @class */ (function (_super) {
31
40
  return InvalidStateError;
32
41
  }(common_1.ErrBase.CustomError));
33
42
  exports.InvalidStateError = InvalidStateError;
43
+ /**
44
+ * Error indicating incorrect usage of the API.
45
+ */
34
46
  var InvalidUsageError = /** @class */ (function (_super) {
35
47
  tslib_1.__extends(InvalidUsageError, _super);
36
48
  function InvalidUsageError() {
@@ -39,15 +51,28 @@ var InvalidUsageError = /** @class */ (function (_super) {
39
51
  return InvalidUsageError;
40
52
  }(common_1.ErrBase.CustomError));
41
53
  exports.InvalidUsageError = InvalidUsageError;
54
+ /**
55
+ * Throws an `EmptyCollectionAssumedNonEmptyError`.
56
+ */
42
57
  function throwEmptyCollectionAssumedNonEmptyError() {
43
58
  throw new EmptyCollectionAssumedNonEmptyError();
44
59
  }
60
+ /**
61
+ * Throws a `ModifiedBuilderWhileLoopingOverItError`.
62
+ */
45
63
  function throwModifiedBuilderWhileLoopingOverItError() {
46
64
  throw new ModifiedBuilderWhileLoopingOverItError();
47
65
  }
66
+ /**
67
+ * Throws an `InvalidStateError`.
68
+ */
48
69
  function throwInvalidStateError() {
49
70
  throw new InvalidStateError();
50
71
  }
72
+ /**
73
+ * Throws an `InvalidUsageError` with the provided message.
74
+ * @param msg - context message describing the invalid usage
75
+ */
51
76
  function throwInvalidUsageError(msg) {
52
77
  throw new InvalidUsageError(msg);
53
78
  }
@@ -1 +1 @@
1
- {"version":3,"file":"rimbu-error.cjs","sourceRoot":"","sources":["../../_cjs_prepare/rimbu-error.cts"],"names":[],"mappings":";;;AAwBA,4FAEC;AAED,kGAEC;AAED,wDAEC;AAED,wDAEC;;AAtCD,wCAAwC;AAExC;IAAyD,+DAAmB;IAC1E;QACE,OAAA,MAAK,YAAC,+CAA+C,CAAC,SAAC;IACzD,CAAC;IACH,0CAAC;AAAD,CAAC,AAJD,CAAyD,gBAAO,CAAC,WAAW,GAI3E;AAJY,kFAAmC;AAMhD;IAA4D,kEAAmB;IAC7E;QACE,OAAA,MAAK,YAAC,+DAA+D,CAAC,SAAC;IACzE,CAAC;IACH,6CAAC;AAAD,CAAC,AAJD,CAA4D,gBAAO,CAAC,WAAW,GAI9E;AAJY,wFAAsC;AAMnD;IAAuC,6CAAmB;IACxD;QACE,OAAA,MAAK,YACH,4EAA4E,CAC7E,SAAC;IACJ,CAAC;IACH,wBAAC;AAAD,CAAC,AAND,CAAuC,gBAAO,CAAC,WAAW,GAMzD;AANY,8CAAiB;AAQ9B;IAAuC,6CAAmB;IAA1D;;IAA4D,CAAC;IAAD,wBAAC;AAAD,CAAC,AAA7D,CAAuC,gBAAO,CAAC,WAAW,GAAG;AAAhD,8CAAiB;AAE9B,SAAgB,wCAAwC;IACtD,MAAM,IAAI,mCAAmC,EAAE,CAAC;AAClD,CAAC;AAED,SAAgB,2CAA2C;IACzD,MAAM,IAAI,sCAAsC,EAAE,CAAC;AACrD,CAAC;AAED,SAAgB,sBAAsB;IACpC,MAAM,IAAI,iBAAiB,EAAE,CAAC;AAChC,CAAC;AAED,SAAgB,sBAAsB,CAAC,GAAW;IAChD,MAAM,IAAI,iBAAiB,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC"}
1
+ {"version":3,"file":"rimbu-error.cjs","sourceRoot":"","sources":["../../_cjs_prepare/rimbu-error.cts"],"names":[],"mappings":";;;AAuCA,4FAEC;AAKD,kGAEC;AAKD,wDAEC;AAMD,wDAEC;;AA/DD,wCAAwC;AAExC;;GAEG;AACH;IAAyD,+DAAmB;IAC1E;QACE,OAAA,MAAK,YAAC,+CAA+C,CAAC,SAAC;IACzD,CAAC;IACH,0CAAC;AAAD,CAAC,AAJD,CAAyD,gBAAO,CAAC,WAAW,GAI3E;AAJY,kFAAmC;AAMhD;;GAEG;AACH;IAA4D,kEAAmB;IAC7E;QACE,OAAA,MAAK,YAAC,+DAA+D,CAAC,SAAC;IACzE,CAAC;IACH,6CAAC;AAAD,CAAC,AAJD,CAA4D,gBAAO,CAAC,WAAW,GAI9E;AAJY,wFAAsC;AAMnD;;GAEG;AACH;IAAuC,6CAAmB;IACxD;QACE,OAAA,MAAK,YACH,4EAA4E,CAC7E,SAAC;IACJ,CAAC;IACH,wBAAC;AAAD,CAAC,AAND,CAAuC,gBAAO,CAAC,WAAW,GAMzD;AANY,8CAAiB;AAQ9B;;GAEG;AACH;IAAuC,6CAAmB;IAA1D;;IAA4D,CAAC;IAAD,wBAAC;AAAD,CAAC,AAA7D,CAAuC,gBAAO,CAAC,WAAW,GAAG;AAAhD,8CAAiB;AAE9B;;GAEG;AACH,SAAgB,wCAAwC;IACtD,MAAM,IAAI,mCAAmC,EAAE,CAAC;AAClD,CAAC;AAED;;GAEG;AACH,SAAgB,2CAA2C;IACzD,MAAM,IAAI,sCAAsC,EAAE,CAAC;AACrD,CAAC;AAED;;GAEG;AACH,SAAgB,sBAAsB;IACpC,MAAM,IAAI,iBAAiB,EAAE,CAAC;AAChC,CAAC;AAED;;;GAGG;AACH,SAAgB,sBAAsB,CAAC,GAAW;IAChD,MAAM,IAAI,iBAAiB,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC"}
@@ -1,16 +1,41 @@
1
1
  import { ErrBase } from '@rimbu/common';
2
+ /**
3
+ * Error thrown when an operation assumes a collection is non-empty but it is empty.
4
+ */
2
5
  export declare class EmptyCollectionAssumedNonEmptyError extends ErrBase.CustomError {
3
6
  constructor();
4
7
  }
8
+ /**
9
+ * Error thrown when a builder is modified while it is being iterated.
10
+ */
5
11
  export declare class ModifiedBuilderWhileLoopingOverItError extends ErrBase.CustomError {
6
12
  constructor();
7
13
  }
14
+ /**
15
+ * Error indicating an unexpected internal state. Users are encouraged to file an issue.
16
+ */
8
17
  export declare class InvalidStateError extends ErrBase.CustomError {
9
18
  constructor();
10
19
  }
20
+ /**
21
+ * Error indicating incorrect usage of the API.
22
+ */
11
23
  export declare class InvalidUsageError extends ErrBase.CustomError {
12
24
  }
25
+ /**
26
+ * Throws an `EmptyCollectionAssumedNonEmptyError`.
27
+ */
13
28
  export declare function throwEmptyCollectionAssumedNonEmptyError(): never;
29
+ /**
30
+ * Throws a `ModifiedBuilderWhileLoopingOverItError`.
31
+ */
14
32
  export declare function throwModifiedBuilderWhileLoopingOverItError(): never;
33
+ /**
34
+ * Throws an `InvalidStateError`.
35
+ */
15
36
  export declare function throwInvalidStateError(): never;
37
+ /**
38
+ * Throws an `InvalidUsageError` with the provided message.
39
+ * @param msg - context message describing the invalid usage
40
+ */
16
41
  export declare function throwInvalidUsageError(msg: string): never;
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Token = void 0;
4
+ /**
5
+ * Unique symbol used as a nominal token within the base package.
6
+ * Can be employed for branding or sentinel values.
7
+ */
4
8
  exports.Token = Symbol('Token');
5
9
  //# sourceMappingURL=token.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"token.cjs","sourceRoot":"","sources":["../../_cjs_prepare/token.cts"],"names":[],"mappings":";;;AAAa,QAAA,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC"}
1
+ {"version":3,"file":"token.cjs","sourceRoot":"","sources":["../../_cjs_prepare/token.cts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC"}
@@ -1,2 +1,9 @@
1
+ /**
2
+ * Unique symbol used as a nominal token within the base package.
3
+ * Can be employed for branding or sentinel values.
4
+ */
1
5
  export declare const Token: unique symbol;
6
+ /**
7
+ * Type alias representing the Token symbol.
8
+ */
2
9
  export type Token = typeof Token;
@@ -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[];