ts-data-forge 12.0.0 → 12.2.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.
@@ -1,4 +1,4 @@
1
- import { type BoundedLengthArray, type FixedLengthArray, type MaxLengthArray, type MinLengthArray, type SupportedLength } from 'ts-type-forge';
1
+ import { type BoundedLengthArray, type FixedLengthArray, type MaxLengthArray, type MinLengthArray, type NonEmptyArray, type SupportedLength } from 'ts-type-forge';
2
2
  /**
3
3
  * Casts an array to `FixedLengthArray<Length, E>` after checking that it has
4
4
  * exactly `length` elements.
@@ -9,6 +9,9 @@ import { type BoundedLengthArray, type FixedLengthArray, type MaxLengthArray, ty
9
9
  * structural tuple prefix (in-range indexed access without `undefined` under
10
10
  * `noUncheckedIndexedAccess`).
11
11
  *
12
+ * Supports a curried overload: calling it with only `length` returns a
13
+ * function that casts an array, which is convenient for `pipe`/`map`.
14
+ *
12
15
  * @example
13
16
  *
14
17
  * ```ts
@@ -17,6 +20,10 @@ import { type BoundedLengthArray, type FixedLengthArray, type MaxLengthArray, ty
17
20
  * const atMost5: MaxLengthArray<5, number> = rgb; // OK (3 <= 5)
18
21
  * const red: number = rgb[0]; // OK — no `undefined`
19
22
  *
23
+ * // curried version
24
+ * const asRgb = Arr.asFixedLengthArray(3);
25
+ * const green = asRgb([0, 255, 0]);
26
+ *
20
27
  * // Arr.asFixedLengthArray([255, 128], 3); // throws TypeError
21
28
  * ```
22
29
  *
@@ -27,7 +34,8 @@ import { type BoundedLengthArray, type FixedLengthArray, type MaxLengthArray, ty
27
34
  * @returns `xs` typed as `FixedLengthArray<Length, Xs[number]> & Xs`.
28
35
  * @throws {TypeError} If `xs.length !== length`.
29
36
  */
30
- export declare const asFixedLengthArray: <Xs extends readonly unknown[], Length extends SupportedLength>(xs: Xs, length: Length) => FixedLengthArray<Length, Xs[number]> & Xs;
37
+ export declare function asFixedLengthArray<Xs extends readonly unknown[], Length extends SupportedLength>(xs: Xs, length: Length): FixedLengthArray<Length, Xs[number]> & Xs;
38
+ export declare function asFixedLengthArray<Length extends SupportedLength>(length: Length): <Xs extends readonly unknown[]>(xs: Xs) => FixedLengthArray<Length, Xs[number]> & Xs;
31
39
  /**
32
40
  * Casts an array to `MinLengthArray<MinLength, E>` after checking that it has
33
41
  * at least `minLength` elements.
@@ -38,6 +46,9 @@ export declare const asFixedLengthArray: <Xs extends readonly unknown[], Length
38
46
  * structural tuple prefix (indexed access below `min(N, 10)` without
39
47
  * `undefined` under `noUncheckedIndexedAccess`).
40
48
  *
49
+ * Supports a curried overload: calling it with only `minLength` returns a
50
+ * function that casts an array, which is convenient for `pipe`/`map`.
51
+ *
41
52
  * @example
42
53
  *
43
54
  * ```ts
@@ -46,6 +57,10 @@ export declare const asFixedLengthArray: <Xs extends readonly unknown[], Length
46
57
  * const nonEmpty: MinLengthArray<1, number> = history; // OK (3 >= 1)
47
58
  * const first: number = history[0]; // OK — no `undefined`
48
59
  *
60
+ * // curried version
61
+ * const asHistory = Arr.asMinLengthArray(3);
62
+ * const next = asHistory([4, 5, 6, 7]);
63
+ *
49
64
  * // Arr.asMinLengthArray([0], 3); // throws TypeError
50
65
  * ```
51
66
  *
@@ -56,7 +71,8 @@ export declare const asFixedLengthArray: <Xs extends readonly unknown[], Length
56
71
  * @returns `xs` typed as `MinLengthArray<MinLength, Xs[number]> & Xs`.
57
72
  * @throws {TypeError} If `xs.length < minLength`.
58
73
  */
59
- export declare const asMinLengthArray: <Xs extends readonly unknown[], MinLength extends SupportedLength>(xs: Xs, minLength: MinLength) => MinLengthArray<MinLength, Xs[number]> & Xs;
74
+ export declare function asMinLengthArray<Xs extends readonly unknown[], MinLength extends SupportedLength>(xs: Xs, minLength: MinLength): MinLengthArray<MinLength, Xs[number]> & Xs;
75
+ export declare function asMinLengthArray<MinLength extends SupportedLength>(minLength: MinLength): <Xs extends readonly unknown[]>(xs: Xs) => MinLengthArray<MinLength, Xs[number]> & Xs;
60
76
  /**
61
77
  * Casts an array to `MaxLengthArray<MaxLength, E>` after checking that it has
62
78
  * at most `maxLength` elements.
@@ -65,6 +81,9 @@ export declare const asMinLengthArray: <Xs extends readonly unknown[], MinLength
65
81
  * length is verified at runtime, and the original array type (e.g. tuple
66
82
  * types) is preserved via intersection.
67
83
  *
84
+ * Supports a curried overload: calling it with only `maxLength` returns a
85
+ * function that casts an array, which is convenient for `pipe`/`map`.
86
+ *
68
87
  * @example
69
88
  *
70
89
  * ```ts
@@ -72,6 +91,10 @@ export declare const asMinLengthArray: <Xs extends readonly unknown[], MinLength
72
91
  *
73
92
  * const relaxed: MaxLengthArray<16, string> = tags; // OK (8 <= 16)
74
93
  *
94
+ * // curried version
95
+ * const asTags = Arr.asMaxLengthArray(8);
96
+ * const more = asTags(['d', 'e']);
97
+ *
75
98
  * // Arr.asMaxLengthArray(['a', 'b', 'c'], 2); // throws TypeError
76
99
  * ```
77
100
  *
@@ -82,7 +105,8 @@ export declare const asMinLengthArray: <Xs extends readonly unknown[], MinLength
82
105
  * @returns `xs` typed as `MaxLengthArray<MaxLength, Xs[number]> & Xs`.
83
106
  * @throws {TypeError} If `xs.length > maxLength`.
84
107
  */
85
- export declare const asMaxLengthArray: <Xs extends readonly unknown[], MaxLength extends SupportedLength>(xs: Xs, maxLength: MaxLength) => MaxLengthArray<MaxLength, Xs[number]> & Xs;
108
+ export declare function asMaxLengthArray<Xs extends readonly unknown[], MaxLength extends SupportedLength>(xs: Xs, maxLength: MaxLength): MaxLengthArray<MaxLength, Xs[number]> & Xs;
109
+ export declare function asMaxLengthArray<MaxLength extends SupportedLength>(maxLength: MaxLength): <Xs extends readonly unknown[]>(xs: Xs) => MaxLengthArray<MaxLength, Xs[number]> & Xs;
86
110
  /**
87
111
  * Casts an array to `BoundedLengthArray<MinLength, MaxLength, E>` after
88
112
  * checking that its length is within the inclusive range
@@ -93,6 +117,10 @@ export declare const asMaxLengthArray: <Xs extends readonly unknown[], MaxLength
93
117
  * at runtime, and the original array type (e.g. tuple types) is preserved via
94
118
  * intersection.
95
119
  *
120
+ * Supports a curried overload: calling it with only `minLength` and
121
+ * `maxLength` returns a function that casts an array, which is convenient for
122
+ * `pipe`/`map`.
123
+ *
96
124
  * @example
97
125
  *
98
126
  * ```ts
@@ -100,6 +128,10 @@ export declare const asMaxLengthArray: <Xs extends readonly unknown[], MaxLength
100
128
  *
101
129
  * const relaxed: BoundedLengthArray<0, 100, number> = selection; // OK
102
130
  *
131
+ * // curried version
132
+ * const asSelection = Arr.asBoundedLengthArray(1, 5);
133
+ * const next = asSelection([4, 5]);
134
+ *
103
135
  * // Arr.asBoundedLengthArray([], 1, 5); // throws TypeError
104
136
  * ```
105
137
  *
@@ -113,5 +145,33 @@ export declare const asMaxLengthArray: <Xs extends readonly unknown[], MaxLength
113
145
  * `BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs`.
114
146
  * @throws {TypeError} If `xs.length < minLength || xs.length > maxLength`.
115
147
  */
116
- export declare const asBoundedLengthArray: <Xs extends readonly unknown[], MinLength extends SupportedLength, MaxLength extends SupportedLength>(xs: Xs, minLength: MinLength, maxLength: MaxLength) => BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs;
148
+ export declare function asBoundedLengthArray<Xs extends readonly unknown[], MinLength extends SupportedLength, MaxLength extends SupportedLength>(xs: Xs, minLength: MinLength, maxLength: MaxLength): BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs;
149
+ export declare function asBoundedLengthArray<MinLength extends SupportedLength, MaxLength extends SupportedLength>(minLength: MinLength, maxLength: MaxLength): <Xs extends readonly unknown[]>(xs: Xs) => BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs;
150
+ /**
151
+ * Casts an array to `NonEmptyArray<E>` after checking that it has at least one
152
+ * element.
153
+ *
154
+ * `NonEmptyArray<E>` is an alias of `MinLengthArray<1, E>`, so this is the
155
+ * length-1 specialization of {@link asMinLengthArray}. Use this instead of
156
+ * writing `xs as unknown as NonEmptyArray<E>`: the length is verified at
157
+ * runtime, and the original array type (e.g. tuple types) is preserved via
158
+ * intersection, so the result also benefits from the structural tuple prefix
159
+ * (`xs[0]` without `undefined` under `noUncheckedIndexedAccess`).
160
+ *
161
+ * @example
162
+ *
163
+ * ```ts
164
+ * const history = Arr.asNonEmptyArray([0, 1, 2, 3]);
165
+ *
166
+ * const first: number = history[0]; // OK — no `undefined`
167
+ *
168
+ * // Arr.asNonEmptyArray([]); // throws TypeError
169
+ * ```
170
+ *
171
+ * @template Xs - The input array type (tuple types are preserved).
172
+ * @param xs - The array to cast.
173
+ * @returns `xs` typed as `NonEmptyArray<Xs[number]> & Xs`.
174
+ * @throws {TypeError} If `xs` is empty.
175
+ */
176
+ export declare const asNonEmptyArray: <Xs extends readonly unknown[]>(xs: Xs) => NonEmptyArray<Xs[number]> & Xs;
117
177
  //# sourceMappingURL=array-utils-length-bounded-array-cast.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"array-utils-length-bounded-array-cast.d.mts","sourceRoot":"","sources":["../../../src/array/impl/array-utils-length-bounded-array-cast.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAQvB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,kBAAkB,GAC7B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,MAAM,SAAS,eAAe,MAE1B,EAAE,UACE,MAAM,KACb,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAQzC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,gBAAgB,GAC3B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,SAAS,SAAS,eAAe,MAE7B,EAAE,aACK,SAAS,KACnB,cAAc,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAQ1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,gBAAgB,GAC3B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,SAAS,SAAS,eAAe,MAE7B,EAAE,aACK,SAAS,KACnB,cAAc,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAQ1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,oBAAoB,GAC/B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,SAAS,SAAS,eAAe,EACjC,SAAS,SAAS,eAAe,MAE7B,EAAE,aACK,SAAS,aACT,SAAS,KACnB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAQzD,CAAC"}
1
+ {"version":3,"file":"array-utils-length-bounded-array-cast.d.mts","sourceRoot":"","sources":["../../../src/array/impl/array-utils-length-bounded-array-cast.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAQvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,kBAAkB,CAChC,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,MAAM,SAAS,eAAe,EAC9B,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;AAGrE,wBAAgB,kBAAkB,CAAC,MAAM,SAAS,eAAe,EAC/D,MAAM,EAAE,MAAM,GACb,CAAC,EAAE,SAAS,SAAS,OAAO,EAAE,EAC/B,EAAE,EAAE,EAAE,KACH,gBAAgB,CAAC,M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S,EACpB,SAAS,EAAE,SAAS,GACnB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;AAG7D,wBAAgB,oBAAoB,CAClC,SAAS,SAAS,eAAe,EACjC,SAAS,SAAS,eAAe,EAEjC,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,GACnB,CAAC,EAAE,SAAS,SAAS,OAAO,EAAE,EAC/B,EAAE,EAAE,EAAE,KACH,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;AAgC/D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,eAAe,GAAI,EAAE,SAAS,SAAS,OAAO,EAAE,MACvD,EAAE,KACL,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAM9B,CAAC"}
@@ -1,37 +1,79 @@
1
1
  import { isBoundedLengthArray, isFixedLengthArray, isMaxLengthArray, isMinLengthArray } from './array-utils-length-bounded-array-guard.mjs';
2
2
 
3
- const asFixedLengthArray = (xs, length) => {
4
- if (!isFixedLengthArray(xs, length)) {
5
- throw new TypeError(
6
- `Expected an array of length ${length}, got an array of length ${xs.length}`
7
- );
3
+ function asFixedLengthArray(...args) {
4
+ switch (args.length) {
5
+ case 2: {
6
+ const [xs, length] = args;
7
+ if (!isFixedLengthArray(xs, length)) {
8
+ throw new TypeError(
9
+ `Expected an array of length ${length}, got an array of length ${xs.length}`
10
+ );
11
+ }
12
+ return xs;
13
+ }
14
+ case 1: {
15
+ const [length] = args;
16
+ return (xs) => asFixedLengthArray(xs, length);
17
+ }
8
18
  }
9
- return xs;
10
- };
11
- const asMinLengthArray = (xs, minLength) => {
12
- if (!isMinLengthArray(xs, minLength)) {
13
- throw new TypeError(
14
- `Expected an array of length >= ${minLength}, got an array of length ${xs.length}`
15
- );
19
+ }
20
+ function asMinLengthArray(...args) {
21
+ switch (args.length) {
22
+ case 2: {
23
+ const [xs, minLength] = args;
24
+ if (!isMinLengthArray(xs, minLength)) {
25
+ throw new TypeError(
26
+ `Expected an array of length >= ${minLength}, got an array of length ${xs.length}`
27
+ );
28
+ }
29
+ return xs;
30
+ }
31
+ case 1: {
32
+ const [minLength] = args;
33
+ return (xs) => asMinLengthArray(xs, minLength);
34
+ }
16
35
  }
17
- return xs;
18
- };
19
- const asMaxLengthArray = (xs, maxLength) => {
20
- if (!isMaxLengthArray(xs, maxLength)) {
21
- throw new TypeError(
22
- `Expected an array of length <= ${maxLength}, got an array of length ${xs.length}`
23
- );
36
+ }
37
+ function asMaxLengthArray(...args) {
38
+ switch (args.length) {
39
+ case 2: {
40
+ const [xs, maxLength] = args;
41
+ if (!isMaxLengthArray(xs, maxLength)) {
42
+ throw new TypeError(
43
+ `Expected an array of length <= ${maxLength}, got an array of length ${xs.length}`
44
+ );
45
+ }
46
+ return xs;
47
+ }
48
+ case 1: {
49
+ const [maxLength] = args;
50
+ return (xs) => asMaxLengthArray(xs, maxLength);
51
+ }
24
52
  }
25
- return xs;
26
- };
27
- const asBoundedLengthArray = (xs, minLength, maxLength) => {
28
- if (!isBoundedLengthArray(xs, minLength, maxLength)) {
29
- throw new TypeError(
30
- `Expected an array of length in [${minLength}, ${maxLength}], got an array of length ${xs.length}`
31
- );
53
+ }
54
+ function asBoundedLengthArray(...args) {
55
+ switch (args.length) {
56
+ case 3: {
57
+ const [xs, minLength, maxLength] = args;
58
+ if (!isBoundedLengthArray(xs, minLength, maxLength)) {
59
+ throw new TypeError(
60
+ `Expected an array of length in [${minLength}, ${maxLength}], got an array of length ${xs.length}`
61
+ );
62
+ }
63
+ return xs;
64
+ }
65
+ case 2: {
66
+ const [minLength, maxLength] = args;
67
+ return (xs) => asBoundedLengthArray(xs, minLength, maxLength);
68
+ }
69
+ }
70
+ }
71
+ const asNonEmptyArray = (xs) => {
72
+ if (!isMinLengthArray(xs, 1)) {
73
+ throw new TypeError("Expected a non-empty array, got an empty array");
32
74
  }
33
75
  return xs;
34
76
  };
35
77
 
36
- export { asBoundedLengthArray, asFixedLengthArray, asMaxLengthArray, asMinLengthArray };
78
+ export { asBoundedLengthArray, asFixedLengthArray, asMaxLengthArray, asMinLengthArray, asNonEmptyArray };
37
79
  //# sourceMappingURL=array-utils-length-bounded-array-cast.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"array-utils-length-bounded-array-cast.mjs","sources":["../../../src/array/impl/array-utils-length-bounded-array-cast.mts"],"sourcesContent":["import {\n type BoundedLengthArray,\n type FixedLengthArray,\n type MaxLengthArray,\n type MinLengthArray,\n type SupportedLength,\n} from 'ts-type-forge';\nimport {\n isBoundedLengthArray,\n isFixedLengthArray,\n isMaxLengthArray,\n isMinLengthArray,\n} from './array-utils-length-bounded-array-guard.mjs';\n\n/**\n * Casts an array to `FixedLengthArray<Length, E>` after checking that it has\n * exactly `length` elements.\n *\n * Use this instead of writing `xs as unknown as FixedLengthArray<N, E>`: the\n * length is verified at runtime, and the original array type (e.g. tuple\n * types) is preserved via intersection, so the result also benefits from the\n * structural tuple prefix (in-range indexed access without `undefined` under\n * `noUncheckedIndexedAccess`).\n *\n * @example\n *\n * ```ts\n * const rgb = Arr.asFixedLengthArray([255, 128, 0], 3);\n *\n * const atMost5: MaxLengthArray<5, number> = rgb; // OK (3 <= 5)\n * const red: number = rgb[0]; // OK — no `undefined`\n *\n * // Arr.asFixedLengthArray([255, 128], 3); // throws TypeError\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template Length - The exact number of elements.\n * @param xs - The array to cast.\n * @param length - The exact number of elements.\n * @returns `xs` typed as `FixedLengthArray<Length, Xs[number]> & Xs`.\n * @throws {TypeError} If `xs.length !== length`.\n */\nexport const asFixedLengthArray = <\n Xs extends readonly unknown[],\n Length extends SupportedLength,\n>(\n xs: Xs,\n length: Length,\n): FixedLengthArray<Length, Xs[number]> & Xs => {\n if (!isFixedLengthArray(xs, length)) {\n throw new TypeError(\n `Expected an array of length ${length}, got an array of length ${xs.length}`,\n );\n }\n\n return xs;\n};\n\n/**\n * Casts an array to `MinLengthArray<MinLength, E>` after checking that it has\n * at least `minLength` elements.\n *\n * Use this instead of writing `xs as unknown as MinLengthArray<N, E>`: the\n * length is verified at runtime, and the original array type (e.g. tuple\n * types) is preserved via intersection, so the result also benefits from the\n * structural tuple prefix (indexed access below `min(N, 10)` without\n * `undefined` under `noUncheckedIndexedAccess`).\n *\n * @example\n *\n * ```ts\n * const history = Arr.asMinLengthArray([0, 1, 2, 3], 3);\n *\n * const nonEmpty: MinLengthArray<1, number> = history; // OK (3 >= 1)\n * const first: number = history[0]; // OK — no `undefined`\n *\n * // Arr.asMinLengthArray([0], 3); // throws TypeError\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template MinLength - The minimum number of elements (inclusive).\n * @param xs - The array to cast.\n * @param minLength - The minimum number of elements (inclusive).\n * @returns `xs` typed as `MinLengthArray<MinLength, Xs[number]> & Xs`.\n * @throws {TypeError} If `xs.length < minLength`.\n */\nexport const asMinLengthArray = <\n Xs extends readonly unknown[],\n MinLength extends SupportedLength,\n>(\n xs: Xs,\n minLength: MinLength,\n): MinLengthArray<MinLength, Xs[number]> & Xs => {\n if (!isMinLengthArray(xs, minLength)) {\n throw new TypeError(\n `Expected an array of length >= ${minLength}, got an array of length ${xs.length}`,\n );\n }\n\n return xs;\n};\n\n/**\n * Casts an array to `MaxLengthArray<MaxLength, E>` after checking that it has\n * at most `maxLength` elements.\n *\n * Use this instead of writing `xs as unknown as MaxLengthArray<N, E>`: the\n * length is verified at runtime, and the original array type (e.g. tuple\n * types) is preserved via intersection.\n *\n * @example\n *\n * ```ts\n * const tags = Arr.asMaxLengthArray(['a', 'b', 'c'], 8);\n *\n * const relaxed: MaxLengthArray<16, string> = tags; // OK (8 <= 16)\n *\n * // Arr.asMaxLengthArray(['a', 'b', 'c'], 2); // throws TypeError\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template MaxLength - The maximum number of elements (inclusive).\n * @param xs - The array to cast.\n * @param maxLength - The maximum number of elements (inclusive).\n * @returns `xs` typed as `MaxLengthArray<MaxLength, Xs[number]> & Xs`.\n * @throws {TypeError} If `xs.length > maxLength`.\n */\nexport const asMaxLengthArray = <\n Xs extends readonly unknown[],\n MaxLength extends SupportedLength,\n>(\n xs: Xs,\n maxLength: MaxLength,\n): MaxLengthArray<MaxLength, Xs[number]> & Xs => {\n if (!isMaxLengthArray(xs, maxLength)) {\n throw new TypeError(\n `Expected an array of length <= ${maxLength}, got an array of length ${xs.length}`,\n );\n }\n\n return xs;\n};\n\n/**\n * Casts an array to `BoundedLengthArray<MinLength, MaxLength, E>` after\n * checking that its length is within the inclusive range\n * `[minLength, maxLength]`.\n *\n * Use this instead of writing\n * `xs as unknown as BoundedLengthArray<Min, Max, E>`: the length is verified\n * at runtime, and the original array type (e.g. tuple types) is preserved via\n * intersection.\n *\n * @example\n *\n * ```ts\n * const selection = Arr.asBoundedLengthArray([1, 2, 3], 1, 5);\n *\n * const relaxed: BoundedLengthArray<0, 100, number> = selection; // OK\n *\n * // Arr.asBoundedLengthArray([], 1, 5); // throws TypeError\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template MinLength - The minimum number of elements (inclusive).\n * @template MaxLength - The maximum number of elements (inclusive).\n * @param xs - The array to cast.\n * @param minLength - The minimum number of elements (inclusive).\n * @param maxLength - The maximum number of elements (inclusive).\n * @returns `xs` typed as\n * `BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs`.\n * @throws {TypeError} If `xs.length < minLength || xs.length > maxLength`.\n */\nexport const asBoundedLengthArray = <\n Xs extends readonly unknown[],\n MinLength extends SupportedLength,\n MaxLength extends SupportedLength,\n>(\n xs: Xs,\n minLength: MinLength,\n maxLength: MaxLength,\n): BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs => {\n if (!isBoundedLengthArray(xs, minLength, maxLength)) {\n throw new TypeError(\n `Expected an array of length in [${minLength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A,EACF;AAEA,EAAA,OAAO,EAAA;AACT;;;;"}
1
+ {"version":3,"file":"array-utils-length-bounded-array-cast.mjs","sources":["../../../src/array/impl/array-utils-length-bounded-array-cast.mts"],"sourcesContent":["import {\n type BoundedLengthArray,\n type FixedLengthArray,\n type MaxLengthArray,\n type MinLengthArray,\n type NonEmptyArray,\n type SupportedLength,\n} from 'ts-type-forge';\nimport {\n isBoundedLengthArray,\n isFixedLengthArray,\n isMaxLengthArray,\n isMinLengthArray,\n} from './array-utils-length-bounded-array-guard.mjs';\n\n/**\n * Casts an array to `FixedLengthArray<Length, E>` after checking that it has\n * exactly `length` elements.\n *\n * Use this instead of writing `xs as unknown as FixedLengthArray<N, E>`: the\n * length is verified at runtime, and the original array type (e.g. tuple\n * types) is preserved via intersection, so the result also benefits from the\n * structural tuple prefix (in-range indexed access without `undefined` under\n * `noUncheckedIndexedAccess`).\n *\n * Supports a curried overload: calling it with only `length` returns a\n * function that casts an array, which is convenient for `pipe`/`map`.\n *\n * @example\n *\n * ```ts\n * const rgb = Arr.asFixedLengthArray([255, 128, 0], 3);\n *\n * const atMost5: MaxLengthArray<5, number> = rgb; // OK (3 <= 5)\n * const red: number = rgb[0]; // OK — no `undefined`\n *\n * // curried version\n * const asRgb = Arr.asFixedLengthArray(3);\n * const green = asRgb([0, 255, 0]);\n *\n * // Arr.asFixedLengthArray([255, 128], 3); // throws TypeError\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template Length - The exact number of elements.\n * @param xs - The array to cast.\n * @param length - The exact number of elements.\n * @returns `xs` typed as `FixedLengthArray<Length, Xs[number]> & Xs`.\n * @throws {TypeError} If `xs.length !== length`.\n */\nexport function asFixedLengthArray<\n Xs extends readonly unknown[],\n Length extends SupportedLength,\n>(xs: Xs, length: Length): FixedLengthArray<Length, Xs[number]> & Xs;\n\n// Curried version\nexport function asFixedLengthArray<Length extends SupportedLength>(\n length: Length,\n): <Xs extends readonly unknown[]>(\n xs: Xs,\n) => FixedLengthArray<Length, Xs[number]> & Xs;\n\nexport function asFixedLengthArray<E>(\n ...args:\n | readonly [xs: readonly E[], length: SupportedLength]\n | readonly [length: SupportedLength]\n): readonly E[] | ((xs: readonly E[]) => readonly E[]) {\n switch (args.length) {\n case 2: {\n const [xs, length] = args;\n\n if (!isFixedLengthArray(xs, length)) {\n throw new TypeError(\n `Expected an array of length ${length}, got an array of length ${xs.length}`,\n );\n }\n\n return xs;\n }\n\n case 1: {\n const [length] = args;\n\n return (xs) => asFixedLengthArray(xs, length);\n }\n }\n}\n\n/**\n * Casts an array to `MinLengthArray<MinLength, E>` after checking that it has\n * at least `minLength` elements.\n *\n * Use this instead of writing `xs as unknown as MinLengthArray<N, E>`: the\n * length is verified at runtime, and the original array type (e.g. tuple\n * types) is preserved via intersection, so the result also benefits from the\n * structural tuple prefix (indexed access below `min(N, 10)` without\n * `undefined` under `noUncheckedIndexedAccess`).\n *\n * Supports a curried overload: calling it with only `minLength` returns a\n * function that casts an array, which is convenient for `pipe`/`map`.\n *\n * @example\n *\n * ```ts\n * const history = Arr.asMinLengthArray([0, 1, 2, 3], 3);\n *\n * const nonEmpty: MinLengthArray<1, number> = history; // OK (3 >= 1)\n * const first: number = history[0]; // OK — no `undefined`\n *\n * // curried version\n * const asHistory = Arr.asMinLengthArray(3);\n * const next = asHistory([4, 5, 6, 7]);\n *\n * // Arr.asMinLengthArray([0], 3); // throws TypeError\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template MinLength - The minimum number of elements (inclusive).\n * @param xs - The array to cast.\n * @param minLength - The minimum number of elements (inclusive).\n * @returns `xs` typed as `MinLengthArray<MinLength, Xs[number]> & Xs`.\n * @throws {TypeError} If `xs.length < minLength`.\n */\nexport function asMinLengthArray<\n Xs extends readonly unknown[],\n MinLength extends SupportedLength,\n>(xs: Xs, minLength: MinLength): MinLengthArray<MinLength, Xs[number]> & Xs;\n\n// Curried version\nexport function asMinLengthArray<MinLength extends SupportedLength>(\n minLength: MinLength,\n): <Xs extends readonly unknown[]>(\n xs: Xs,\n) => MinLengthArray<MinLength, Xs[number]> & Xs;\n\nexport function asMinLengthArray<E>(\n ...args:\n | readonly [xs: readonly E[], minLength: SupportedLength]\n | readonly [minLength: SupportedLength]\n): readonly E[] | ((xs: readonly E[]) => readonly E[]) {\n switch (args.length) {\n case 2: {\n const [xs, minLength] = args;\n\n if (!isMinLengthArray(xs, minLength)) {\n throw new TypeError(\n `Expected an array of length >= ${minLength}, got an array of length ${xs.length}`,\n );\n }\n\n return xs;\n }\n\n case 1: {\n const [minLength] = args;\n\n return (xs) => asMinLengthArray(xs, minLength);\n }\n }\n}\n\n/**\n * Casts an array to `MaxLengthArray<MaxLength, E>` after checking that it has\n * at most `maxLength` elements.\n *\n * Use this instead of writing `xs as unknown as MaxLengthArray<N, E>`: the\n * length is verified at runtime, and the original array type (e.g. tuple\n * types) is preserved via intersection.\n *\n * Supports a curried overload: calling it with only `maxLength` returns a\n * function that casts an array, which is convenient for `pipe`/`map`.\n *\n * @example\n *\n * ```ts\n * const tags = Arr.asMaxLengthArray(['a', 'b', 'c'], 8);\n *\n * const relaxed: MaxLengthArray<16, string> = tags; // OK (8 <= 16)\n *\n * // curried version\n * const asTags = Arr.asMaxLengthArray(8);\n * const more = asTags(['d', 'e']);\n *\n * // Arr.asMaxLengthArray(['a', 'b', 'c'], 2); // throws TypeError\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template MaxLength - The maximum number of elements (inclusive).\n * @param xs - The array to cast.\n * @param maxLength - The maximum number of elements (inclusive).\n * @returns `xs` typed as `MaxLengthArray<MaxLength, Xs[number]> & Xs`.\n * @throws {TypeError} If `xs.length > maxLength`.\n */\nexport function asMaxLengthArray<\n Xs extends readonly unknown[],\n MaxLength extends SupportedLength,\n>(xs: Xs, maxLength: MaxLength): MaxLengthArray<MaxLength, Xs[number]> & Xs;\n\n// Curried version\nexport function asMaxLengthArray<MaxLength extends SupportedLength>(\n maxLength: MaxLength,\n): <Xs extends readonly unknown[]>(\n xs: Xs,\n) => MaxLengthArray<MaxLength, Xs[number]> & Xs;\n\nexport function asMaxLengthArray<E>(\n ...args:\n | readonly [xs: readonly E[], maxLength: SupportedLength]\n | readonly [maxLength: SupportedLength]\n): readonly E[] | ((xs: readonly E[]) => readonly E[]) {\n switch (args.length) {\n case 2: {\n const [xs, maxLength] = args;\n\n if (!isMaxLengthArray(xs, maxLength)) {\n throw new TypeError(\n `Expected an array of length <= ${maxLength}, got an array of length ${xs.length}`,\n );\n }\n\n return xs;\n }\n\n case 1: {\n const [maxLength] = args;\n\n return (xs) => asMaxLengthArray(xs, maxLength);\n }\n }\n}\n\n/**\n * Casts an array to `BoundedLengthArray<MinLength, MaxLength, E>` after\n * checking that its length is within the inclusive range\n * `[minLength, maxLength]`.\n *\n * Use this instead of writing\n * `xs as unknown as BoundedLengthArray<Min, Max, E>`: the length is verified\n * at runtime, and the original array type (e.g. tuple types) is preserved via\n * intersection.\n *\n * Supports a curried overload: calling it with only `minLength` and\n * `maxLength` returns a function that casts an array, which is convenient for\n * `pipe`/`map`.\n *\n * @example\n *\n * ```ts\n * const selection = Arr.asBoundedLengthArray([1, 2, 3], 1, 5);\n *\n * const relaxed: BoundedLengthArray<0, 100, number> = selection; // OK\n *\n * // curried version\n * const asSelection = Arr.asBoundedLengthArray(1, 5);\n * const next = asSelection([4, 5]);\n *\n * // Arr.asBoundedLengthArray([], 1, 5); // throws TypeError\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template MinLength - The minimum number of elements (inclusive).\n * @template MaxLength - The maximum number of elements (inclusive).\n * @param xs - The array to cast.\n * @param minLength - The minimum number of elements (inclusive).\n * @param maxLength - The maximum number of elements (inclusive).\n * @returns `xs` typed as\n * `BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs`.\n * @throws {TypeError} If `xs.length < minLength || xs.length > maxLength`.\n */\nexport function asBoundedLengthArray<\n Xs extends readonly unknown[],\n MinLength extends SupportedLength,\n MaxLength extends SupportedLength,\n>(\n xs: Xs,\n minLength: MinLength,\n maxLength: MaxLength,\n): BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs;\n\n// Curried version\nexport function asBoundedLengthArray<\n MinLength extends SupportedLength,\n MaxLength extends SupportedLength,\n>(\n minLength: MinLength,\n maxLength: MaxLength,\n): <Xs extends readonly unknown[]>(\n xs: Xs,\n) => BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs;\n\nexport function asBoundedLengthArray<E>(\n ...args:\n | readonly [\n xs: readonly E[],\n minLength: SupportedLength,\n maxLength: SupportedLength,\n ]\n | readonly [minLength: SupportedLength, maxLength: SupportedLength]\n): readonly E[] | ((xs: readonly E[]) => readonly E[]) {\n switch (args.length) {\n case 3: {\n const [xs, minLength, maxLength] = args;\n\n if (!isBoundedLengthArray(xs, minLength, maxLength)) {\n throw new TypeError(\n `Expected an array of length in [${minLength}, ${maxLength}], got an array of length ${xs.length}`,\n );\n }\n\n return xs;\n }\n\n case 2: {\n const [minLength, maxLength] = args;\n\n return (xs) => asBoundedLengthArray(xs, minLength, maxLength);\n }\n }\n}\n\n/**\n * Casts an array to `NonEmptyArray<E>` after checking that it has at least one\n * element.\n *\n * `NonEmptyArray<E>` is an alias of `MinLengthArray<1, E>`, so this is the\n * length-1 specialization of {@link asMinLengthArray}. Use this instead of\n * writing `xs as unknown as NonEmptyArray<E>`: the length is verified at\n * runtime, and the original array type (e.g. tuple types) is preserved via\n * intersection, so the result also benefits from the structural tuple prefix\n * (`xs[0]` without `undefined` under `noUncheckedIndexedAccess`).\n *\n * @example\n *\n * ```ts\n * const history = Arr.asNonEmptyArray([0, 1, 2, 3]);\n *\n * const first: number = history[0]; // OK — no `undefined`\n *\n * // Arr.asNonEmptyArray([]); // throws TypeError\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @param xs - The array to cast.\n * @returns `xs` typed as `NonEmptyArray<Xs[number]> & Xs`.\n * @throws {TypeError} If `xs` is empty.\n */\nexport const asNonEmptyArray = <Xs extends readonly unknown[]>(\n xs: Xs,\n): NonEmptyArray<Xs[number]> & Xs => {\n if (!isMinLengthArray(xs, 1)) {\n throw new TypeError('Expected a non-empty array, got an empty array');\n }\n\n return xs;\n};\n"],"names":[],"mappings":";;AA8DO,SAAS,sBACX,IAAA,EAGkD;AACrD,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,EAAA,EAAI,MAAM,CAAA,GAAI,IAAA;AAErB,MAAA,IAAI,CAAC,kBAAA,CAAmB,EAAA,EAAI,MAAM,CAAA,EAAG;AACnC,QAAA,MAAM,IAAI,SAAA;AAAA,UACR,CAAA,4BAAA,EAA+B,MAAM,CAAA,yBAAA,EAA4B,EAAA,CAAG,MAAM,CAAA;AAAA,SAC5E;AAAA,MACF;AAEA,MAAA,OAAO,EAAA;AAAA,IACT;AAAA,IAEA,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,MAAM,CAAA,GAAI,IAAA;AAEjB,MAAA,OAAO,CAAC,EAAA,KAAO,kBAAA,CAAmB,EAAA,EAAI,MAAM,CAAA;AAAA,IAC9C;AAAA;AAEJ;AAiDO,SAAS,oBACX,IAAA,EAGkD;AACrD,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,EAAA,EAAI,SAAS,CAAA,GAAI,IAAA;AAExB,MAAA,IAAI,CAAC,gBAAA,CAAiB,EAAA,EAAI,SAAS,CAAA,EAAG;AACpC,QAAA,MAAM,IAAI,SAAA;AAAA,UACR,CAAA,+BAAA,EAAkC,SAAS,CAAA,yBAAA,EAA4B,EAAA,CAAG,MAAM,CAAA;AAAA,SAClF;AAAA,MACF;AAEA,MAAA,OAAO,EAAA;AAAA,IACT;AAAA,IAEA,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,SAAS,CAAA,GAAI,IAAA;AAEpB,MAAA,OAAO,CAAC,EAAA,KAAO,gBAAA,CAA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;AAAA;AAEJ;AA4BO,MAAM,eAAA,GAAkB,CAC7B,EAAA,KACmC;AACnC,EAAA,IAAI,CAAC,gBAAA,CAAiB,EAAA,EAAI,CAAC,CAAA,EAAG;AAC5B,IAAA,MAAM,IAAI,UAAU,gDAAgD,CAAA;AAAA,EACtE;AAEA,EAAA,OAAO,EAAA;AACT;;;;"}
@@ -96,13 +96,18 @@ export declare function toRemoved(index: SizeType.ArgArrWithNegative): <E>(array
96
96
  *
97
97
  * const appendedCurried = Arr.toPushed(4)(base);
98
98
  *
99
- * assert.deepStrictEqual(appended, [1, 2, 3]);
99
+ * // The result is guaranteed non-empty, so it is assignable to NonEmptyArray.
100
+ * const nonEmpty: NonEmptyArray<number> = appended;
100
101
  *
101
- * assert.deepStrictEqual(appendedCurried, [1, 2, 4]);
102
+ * assert.deepStrictEqual<readonly number[]>(appended, [1, 2, 3]);
103
+ *
104
+ * assert.deepStrictEqual<readonly number[]>(appendedCurried, [1, 2, 4]);
105
+ *
106
+ * assert.isTrue(nonEmpty.length >= 1);
102
107
  * ```
103
108
  */
104
- export declare function toPushed<const Ar extends readonly unknown[], const V>(array: Ar, newValue: V): readonly [...Ar, V];
105
- export declare function toPushed<const V>(newValue: V): <const Ar extends readonly unknown[]>(array: Ar) => readonly [...Ar, V];
109
+ export declare function toPushed<const Ar extends readonly unknown[], const V>(array: Ar, newValue: V): readonly [...Ar, V] & NonEmptyArray<Ar[number] | V>;
110
+ export declare function toPushed<const V>(newValue: V): <const Ar extends readonly unknown[]>(array: Ar) => readonly [...Ar, V] & NonEmptyArray<Ar[number] | V>;
106
111
  /**
107
112
  * Returns a new array with a value prepended to the beginning.
108
113
  *
@@ -115,13 +120,18 @@ export declare function toPushed<const V>(newValue: V): <const Ar extends readon
115
120
  *
116
121
  * const prefixedCurried = Arr.toUnshifted(0)(base);
117
122
  *
118
- * assert.deepStrictEqual(prefixed, [1, 2, 3]);
123
+ * // The result is guaranteed non-empty, so it is assignable to NonEmptyArray.
124
+ * const nonEmpty: NonEmptyArray<number> = prefixed;
125
+ *
126
+ * assert.deepStrictEqual<readonly number[]>(prefixed, [1, 2, 3]);
127
+ *
128
+ * assert.deepStrictEqual<readonly number[]>(prefixedCurried, [0, 2, 3]);
119
129
  *
120
- * assert.deepStrictEqual(prefixedCurried, [0, 2, 3]);
130
+ * assert.isTrue(nonEmpty.length >= 1);
121
131
  * ```
122
132
  */
123
- export declare function toUnshifted<const Ar extends readonly unknown[], const V>(array: Ar, newValue: V): readonly [V, ...Ar];
124
- export declare function toUnshifted<const V>(newValue: V): <const Ar extends readonly unknown[]>(array: Ar) => readonly [V, ...Ar];
133
+ export declare function toUnshifted<const Ar extends readonly unknown[], const V>(array: Ar, newValue: V): readonly [V, ...Ar] & NonEmptyArray<V | Ar[number]>;
134
+ export declare function toUnshifted<const V>(newValue: V): <const Ar extends readonly unknown[]>(array: Ar) => readonly [V, ...Ar] & NonEmptyArray<V | Ar[number]>;
125
135
  /**
126
136
  * Returns a new array with all elements replaced by the specified value.
127
137
  *
@@ -1 +1 @@
1
- {"version":3,"file":"array-utils-modification.d.mts","sourceRoot":"","sources":["../../../src/array/impl/array-utils-modification.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,yBAAyB,EAC9B,KAAK,QAAQ,EACd,MAAM,iBAAiB,CAAC;AAGzB;;;;;;;;;;;;GAYG;AACH,wBAAgB,GAAG,CAAC,KAAK,CAAC,EAAE,SAAS,SAAS,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,EAC3E,KAAK,EAAE,EAAE,EACT,KAAK,EAAE,aAAa,CAAC,EAAE,CAAC,EACxB,QAAQ,EAAE,CAAC,GACV,iBAAiB,CAAC,EAAE,CAAC,SAAS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AE,CAAC,MAAM,CAAC,CAAC,GAC9C,EAAE,SAAS,aAAa,CAAC,OAAO,CAAC,GAC/B,aAAa,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,GAC7B,SAAS,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;AAGlC,wBAAgB,aAAa,CAAC,KAAK,CAAC,CAAC,EACnC,KAAK,EAAE,CAAC,EACR,SAAS,EAAE,SAAS;IAClB,KAAK,EAAE,QAAQ,CAAC,kBAAkB;IAClC,GAAG,EAAE,QAAQ,CAAC,kBAAkB;CACjC,GACA,CAAC,KAAK,CAAC,EAAE,SAAS,SAAS,OAAO,EAAE,EACrC,KAAK,EAAE,EAAE,KACN,iBAAiB,CAAC,EAAE,CAAC,SAAS,IAAI,GACnC,gBAAgB,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,GAC9C,EAAE,SAAS,aAAa,CAAC,OAAO,CAAC,GAC/B,aAAa,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,GAC7B,SAAS,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"array-utils-modification.mjs","sources":["../../../src/array/impl/array-utils-modification.mts"],"sourcesContent":["import {\n type FixedLengthTuple,\n type Increment,\n type IsFixedLengthList,\n type NonEmptyArray,\n type NonEmptyTuple,\n} from 'ts-type-forge';\nimport { asPositiveUint32 } from '../../number/index.mjs';\nimport { castMutable } from '../../others/index.mjs';\nimport {\n type ArgArrayIndex,\n type ArgArrayIndexWithNegative,\n type SizeType,\n} from '../../types.mjs';\nimport { copy, create } from './array-utils-creation.mjs';\n\n/**\n * Returns a new array with an element at the specified index replaced.\n *\n * @example\n *\n * ```ts\n * const scores: readonly number[] = [10, 20, 30] as const;\n *\n * const updated = Arr.set(scores, 1, 25);\n *\n * assert.deepStrictEqual(updated, [10, 25, 30]);\n * ```\n */\nexport function set<const Ar extends readonly unknown[], const V = Ar[number]>(\n array: Ar,\n index: ArgArrayIndex<Ar>,\n newValue: V,\n): IsFixedLengthList<Ar> extends true\n ? Readonly<{ [K in keyof Ar]: Ar[K] | V }>\n : Ar extends NonEmptyTuple<unknown>\n ? NonEmptyArray<Ar[number] | V>\n : readonly (Ar[number] | V)[];\n\n// curried version\nexport function set<const V>(\n index: SizeType.ArgArr,\n newValue: V,\n): <const Ar extends readonly unknown[]>(\n array: Ar,\n) => IsFixedLengthList<Ar> extends true\n ? Readonly<{ [K in keyof Ar]: Ar[K] | V }>\n : Ar extends NonEmptyTuple<unknown>\n ? NonEmptyArray<Ar[number] | V>\n : readonly (Ar[number] | V)[];\n\nexport function set<E, const V = E>(\n ...args:\n | readonly [array: readonly E[], index: SizeType.ArgArr, newValue: V]\n | readonly [index: SizeType.ArgArr, newValue: V]\n): readonly (E | V)[] | ((array: readonly E[]) => readonly (E | V)[]) {\n switch (args.length) {\n case 3: {\n const [array, index, newValue] = args;\n\n return (array as readonly (E | V)[]).with(index, newValue);\n }\n\n case 2: {\n const [index, newValue] = args;\n\n return (array) => set(array, index, newValue);\n }\n }\n}\n\n/**\n * Returns a new array with an element at the specified index updated by applying a function.\n *\n * @example\n *\n * ```ts\n * const temperatures: readonly number[] = [20, 21, 22] as const;\n *\n * const increased = Arr.toUpdated(temperatures, 1, (value) => value + 5);\n *\n * const incrementLast = Arr.toUpdated<number>(\n * 2,\n * (value) => value + 1,\n * )(temperatures);\n *\n * assert.deepStrictEqual(increased, [20, 26, 22]);\n *\n * assert.deepStrictEqual(incrementLast, [20, 21, 23]);\n * ```\n */\nexport function toUpdated<\n const Ar extends readonly unknown[],\n const V = Ar[number],\n>(\n array: Ar,\n index: ArgArrayIndex<Ar>,\n updater: (prev: Ar[number]) => V,\n): IsFixedLengthList<Ar> extends true\n ? Readonly<{ [K in keyof Ar]: Ar[K] | V }>\n : Ar extends NonEmptyTuple<unknown>\n ? NonEmptyArray<Ar[number] | V>\n : readonly (Ar[number] | V)[];\n\n// curried version\nexport function toUpdated<E, const V = E>(\n index: SizeType.ArgArr,\n updater: (prev: E) => V,\n): <const Ar extends readonly E[]>(\n array: Ar,\n) => IsFixedLengthList<Ar> extends true\n ? Readonly<{ [K in keyof Ar]: Ar[K] | V }>\n : Ar extends NonEmptyTuple<unknown>\n ? NonEmptyArray<Ar[number] | V>\n : readonly (Ar[number] | V)[];\n\nexport function toUpdated<E, V = E>(\n ...args:\n | readonly [\n array: readonly E[],\n index: SizeType.ArgArr,\n updater: (prev: E) => V,\n ]\n | readonly [index: SizeType.ArgArr, updater: (prev: E) => V]\n): readonly (E | V)[] | ((array: readonly E[]) => readonly (E | V)[]) {\n switch (args.length) {\n case 3: {\n const [array, index, updater] = args;\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return (array as readonly (E | V)[]).with(index, updater(array[index]!));\n }\n\n case 2: {\n const [index, updater] = args;\n\n return (array) => toUpdated(array, index, updater);\n }\n }\n}\n\n/**\n * Returns a new array with a value inserted at the specified index.\n *\n * @example\n *\n * ```ts\n * const numbers = [1, 2, 4] as const;\n *\n * const withThree = Arr.toInserted(numbers, 2, 3);\n *\n * const appendFive = Arr.toInserted(3, 5)(numbers);\n *\n * assert.deepStrictEqual(withThree, [1, 2, 3, 4]);\n *\n * assert.deepStrictEqual(appendFive, [1, 2, 4, 5]);\n * ```\n */\nexport function toInserted<\n const Ar extends readonly unknown[],\n const V = Ar[number],\n>(\n array: Ar,\n index: ArgArrayIndexWithNegative<Ar>,\n newValue: V,\n): IsFixedLengthList<Ar> extends true\n ? FixedLengthTuple<CastToNumber<Increment<Ar['length']>>, Ar[number] | V>\n : NonEmptyArray<Ar[number] | V>;\n\n// curried version\nexport function toInserted<const V>(\n index: SizeType.ArgArrWithNegative,\n newValue: V,\n): <const Ar extends readonly unknown[]>(\n array: Ar,\n) => IsFixedLengthList<Ar> extends true\n ? FixedLengthTuple<CastToNumber<Increment<Ar['length']>>, Ar[number] | V>\n : NonEmptyArray<Ar[number] | V>;\n\nexport function toInserted<E, const V = E>(\n ...args:\n | readonly [\n array: readonly E[],\n index: SizeType.ArgArrWithNegative,\n newValue: V,\n ]\n | readonly [index: SizeType.ArgArrWithNegative, newValue: V]\n): NonEmptyArray<E | V> | ((array: readonly E[]) => NonEmptyArray<E | V>) {\n switch (args.length) {\n case 3: {\n const [array, index, newValue] = args;\n\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n return (array as readonly (E | V)[]).toSpliced(\n index,\n 0,\n newValue,\n ) as unknown as NonEmptyArray<E | V>;\n }\n\n case 2: {\n const [index, newValue] = args;\n\n return (array) => toInserted(array, index, newValue);\n }\n }\n}\n\ntype CastToNumber<T> = T extends number ? T : never;\n\n/**\n * Returns a new array with the element at the specified index removed.\n *\n * @example\n *\n * ```ts\n * const letters = ['a', 'b', 'c', 'd'] as const;\n *\n * const withoutSecond = Arr.toRemoved(letters, 1);\n *\n * const withoutFirstCurried = Arr.toRemoved(0)(letters);\n *\n * assert.deepStrictEqual(withoutSecond, ['a', 'c', 'd']);\n *\n * assert.deepStrictEqual(withoutFirstCurried, ['b', 'c', 'd']);\n * ```\n */\nexport function toRemoved<const Ar extends readonly unknown[]>(\n array: Ar,\n index: ArgArrayIndexWithNegative<Ar>,\n): readonly Ar[number][];\n\nexport function toRemoved(\n index: SizeType.ArgArrWithNegative,\n): <E>(array: readonly E[]) => readonly E[];\n\nexport function toRemoved<E>(\n ...args:\n | readonly [array: readonly E[], index: SizeType.ArgArrWithNegative]\n | readonly [index: SizeType.ArgArrWithNegative]\n): readonly E[] | ((array: readonly E[]) => readonly E[]) {\n switch (args.length) {\n case 2: {\n const [array, index] = args;\n\n return array.toSpliced(index, 1);\n }\n\n case 1: {\n const [index] = args;\n\n return (array) => toRemoved(array, index);\n }\n }\n}\n\n/**\n * Returns a new array with a value appended to the end.\n *\n * @example\n *\n * ```ts\n * const base = [1, 2] as const;\n *\n * const appended = Arr.toPushed(base, 3);\n *\n * const appendedCurried = Arr.toPushed(4)(base);\n *\n * assert.deepStrictEqual(appended, [1, 2, 3]);\n *\n * assert.deepStrictEqual(appendedCurried, [1, 2, 4]);\n * ```\n */\nexport function toPushed<const Ar extends readonly unknown[], const V>(\n array: Ar,\n newValue: V,\n): readonly [...Ar, V];\n\nexport function toPushed<const V>(\n newValue: V,\n): <const Ar extends readonly unknown[]>(array: Ar) => readonly [...Ar, V];\n\nexport function toPushed<const Ar extends readonly unknown[], const V>(\n ...args: readonly [array: Ar, newValue: V] | readonly [newValue: V]\n): readonly [...Ar, V] | ((array: Ar) => readonly [...Ar, V]) {\n switch (args.length) {\n case 2: {\n const [array, newValue] = args;\n\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n return array.toSpliced(array.length, 0, newValue) as unknown as readonly [\n ...Ar,\n V,\n ];\n }\n\n case 1: {\n const [newValue] = args;\n\n return (array) => toPushed(array, newValue);\n }\n }\n}\n\n/**\n * Returns a new array with a value prepended to the beginning.\n *\n * @example\n *\n * ```ts\n * const base = [2, 3] as const;\n *\n * const prefixed = Arr.toUnshifted(base, 1);\n *\n * const prefixedCurried = Arr.toUnshifted(0)(base);\n *\n * assert.deepStrictEqual(prefixed, [1, 2, 3]);\n *\n * assert.deepStrictEqual(prefixedCurried, [0, 2, 3]);\n * ```\n */\nexport function toUnshifted<const Ar extends readonly unknown[], const V>(\n array: Ar,\n newValue: V,\n): readonly [V, ...Ar];\n\nexport function toUnshifted<const V>(\n newValue: V,\n): <const Ar extends readonly unknown[]>(array: Ar) => readonly [V, ...Ar];\n\nexport function toUnshifted<Ar extends readonly unknown[], const V>(\n ...args: readonly [array: Ar, newValue: V] | readonly [newValue: V]\n): readonly [V, ...Ar] | ((array: Ar) => readonly [V, ...Ar]) {\n switch (args.length) {\n case 2: {\n const [array, newValue] = args;\n\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n return array.toSpliced(0, 0, newValue) as unknown as readonly [V, ...Ar];\n }\n\n case 1: {\n const [newValue] = args;\n\n return (array) => toUnshifted(array, newValue);\n }\n }\n}\n\n/**\n * Returns a new array with all elements replaced by the specified value.\n *\n * @example\n *\n * ```ts\n * const base = [1, 2, 3] as const;\n *\n * const filled = Arr.toFilled(base, 0);\n *\n * const filledCurried = Arr.toFilled('x')(base);\n *\n * assert.deepStrictEqual(filled, [0, 0, 0]);\n *\n * assert.deepStrictEqual(filledCurried, ['x', 'x', 'x']);\n * ```\n */\nexport function toFilled<const Ar extends readonly unknown[], const V>(\n array: Ar,\n value: V,\n): IsFixedLengthList<Ar> extends true\n ? FixedLengthTuple<Ar['length'], V>\n : Ar extends NonEmptyTuple<unknown>\n ? NonEmptyArray<V>\n : readonly V[];\n\n// curried version\nexport function toFilled<const V>(\n value: V,\n): <const Ar extends readonly unknown[]>(\n array: Ar,\n) => IsFixedLengthList<Ar> extends true\n ? FixedLengthTuple<Ar['length'], V>\n : Ar extends NonEmptyTuple<unknown>\n ? NonEmptyArray<V>\n : readonly V[];\n\nexport function toFilled<E>(\n ...args: readonly [array: readonly E[], value: E] | readonly [value: E]\n): readonly E[] | ((array: readonly E[]) => readonly E[]) {\n switch (args.length) {\n case 2: {\n const [array, value] = args;\n\n return create(asPositiveUint32(array.length), value);\n }\n\n case 1: {\n const [value] = args;\n\n return (array) => toFilled(array, value);\n }\n }\n}\n\n/**\n * Returns a new array with elements in the specified range replaced by the specified value.\n *\n * @example\n *\n * ```ts\n * const base = [0, 1, 2, 3, 4] as const;\n *\n * const filledMiddle = Arr.toRangeFilled(base, 9, [1, 4]);\n *\n * const filledPrefix = Arr.toRangeFilled(8, [0, 2])(base);\n *\n * assert.deepStrictEqual(filledMiddle, [0, 9, 9, 9, 4]);\n *\n * assert.deepStrictEqual(filledPrefix, [8, 8, 2, 3, 4]);\n * ```\n */\nexport function toRangeFilled<const Ar extends readonly unknown[], const V>(\n array: Ar,\n value: V,\n fillRange: readonly [\n start: ArgArrayIndexWithNegative<Ar>,\n end: ArgArrayIndexWithNegative<Ar>,\n ],\n): IsFixedLengthList<Ar> extends true\n ? FixedLengthTuple<Ar['length'], V | Ar[number]>\n : Ar extends NonEmptyTuple<unknown>\n ? NonEmptyArray<V | Ar[number]>\n : readonly (V | Ar[number])[];\n\n// curried version\nexport function toRangeFilled<const V>(\n value: V,\n fillRange: readonly [\n start: SizeType.ArgArrWithNegative,\n end: SizeType.ArgArrWithNegative,\n ],\n): <const Ar extends readonly unknown[]>(\n array: Ar,\n) => IsFixedLengthList<Ar> extends true\n ? FixedLengthTuple<Ar['length'], V | Ar[number]>\n : Ar extends NonEmptyTuple<unknown>\n ? NonEmptyArray<V | Ar[number]>\n : readonly (V | Ar[number])[];\n\nexport function toRangeFilled<E, const V>(\n ...args:\n | readonly [\n array: readonly E[],\n value: V,\n fillRange: readonly [\n start: SizeType.ArgArrWithNegative,\n end: SizeType.ArgArrWithNegative,\n ],\n ]\n | readonly [\n value: V,\n fillRange: readonly [\n start: SizeType.ArgArrWithNegative,\n end: SizeType.ArgArrWithNegative,\n ],\n ]\n): readonly (E | V)[] | ((array: readonly E[]) => readonly (E | V)[]) {\n switch (args.length) {\n case 3: {\n const [array, value, [start, end]] = args;\n\n const mut_cp: (E | V)[] = castMutable(copy(array));\n\n mut_cp.fill(value, start, end);\n\n return mut_cp;\n }\n\n case 2: {\n const [value, fillRange] = args;\n\n return (array) => toRangeFilled(array, value, fillRange);\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDO,SAAS,OACX,IAAA,EAGiE;AACpE,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,KAAA,EAAO,KAAA,EAAO,QAAQ,CAAA,GAAI,IAAA;AAEjC,MAAA,OAAQ,KAAA,CAA6B,IAAA,CAAK,KAAA,EAAO,QAAQ,CAAA;AAAA,IAC3D;AAAA,IAEA,KAAK,CAAA,EAAG;AAC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N,MAAA,MAAM,CAAC,KAAA,EAAO,KAAK,CAAA,GAAI,IAAA;AAEvB,MAAA,OAAO,MAAA,CAAO,gBAAA,CAAiB,KAAA,CAAM,MAAM,GAAG,KAAK,CAAA;AAAA,IACrD;AAAA,IAEA,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,KAAK,CAAA,GAAI,IAAA;AAEhB,MAAA,OAAO,CAAC,KAAA,KAAU,QAAA,CAAS,KAAA,EAAO,KAAK,CAAA;AAAA,IACzC;AAAA;AAEJ;AA+CO,SAAS,iBACX,IAAA,EAgBiE;AACpE,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,KAAA,EAAO,KAAA,EAAO,CAAC,KAAA,EAAO,GAAG,CAAC,CAAA,GAAI,IAAA;AAErC,MAAA,MAAM,MAAA,GAAoB,WAAA,CAAY,IAAA,CAAK,KAAK,CAAC,CAAA;AAEjD,MAAA,MAAA,CAAO,IAAA,CAAK,KAAA,EAAO,KAAA,EAAO,GAAG,CAAA;AAE7B,MAAA,OAAO,MAAA;AAAA,IACT;AAAA,IAEA,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,KAAA,EAAO,SAAS,CAAA,GAAI,IAAA;AAE3B,MAAA,OAAO,CAAC,KAAA,KAAU,aAAA,CAAc,KAAA,EAAO,OAAO,SAAS,CAAA;AAAA,IACzD;AAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"array-utils-modification.mjs","sources":["../../../src/array/impl/array-utils-modification.mts"],"sourcesContent":["import {\n type FixedLengthTuple,\n type Increment,\n type IsFixedLengthList,\n type NonEmptyArray,\n type NonEmptyTuple,\n} from 'ts-type-forge';\nimport { asPositiveUint32 } from '../../number/index.mjs';\nimport { castMutable } from '../../others/index.mjs';\nimport {\n type ArgArrayIndex,\n type ArgArrayIndexWithNegative,\n type SizeType,\n} from '../../types.mjs';\nimport { copy, create } from './array-utils-creation.mjs';\n\n/**\n * Returns a new array with an element at the specified index replaced.\n *\n * @example\n *\n * ```ts\n * const scores: readonly number[] = [10, 20, 30] as const;\n *\n * const updated = Arr.set(scores, 1, 25);\n *\n * assert.deepStrictEqual(updated, [10, 25, 30]);\n * ```\n */\nexport function set<const Ar extends readonly unknown[], const V = Ar[number]>(\n array: Ar,\n index: ArgArrayIndex<Ar>,\n newValue: V,\n): IsFixedLengthList<Ar> extends true\n ? Readonly<{ [K in keyof Ar]: Ar[K] | V }>\n : Ar extends NonEmptyTuple<unknown>\n ? NonEmptyArray<Ar[number] | V>\n : readonly (Ar[number] | V)[];\n\n// curried version\nexport function set<const V>(\n index: SizeType.ArgArr,\n newValue: V,\n): <const Ar extends readonly unknown[]>(\n array: Ar,\n) => IsFixedLengthList<Ar> extends true\n ? Readonly<{ [K in keyof Ar]: Ar[K] | V }>\n : Ar extends NonEmptyTuple<unknown>\n ? NonEmptyArray<Ar[number] | V>\n : readonly (Ar[number] | V)[];\n\nexport function set<E, const V = E>(\n ...args:\n | readonly [array: readonly E[], index: SizeType.ArgArr, newValue: V]\n | readonly [index: SizeType.ArgArr, newValue: V]\n): readonly (E | V)[] | ((array: readonly E[]) => readonly (E | V)[]) {\n switch (args.length) {\n case 3: {\n const [array, index, newValue] = args;\n\n return (array as readonly (E | V)[]).with(index, newValue);\n }\n\n case 2: {\n const [index, newValue] = args;\n\n return (array) => set(array, index, newValue);\n }\n }\n}\n\n/**\n * Returns a new array with an element at the specified index updated by applying a function.\n *\n * @example\n *\n * ```ts\n * const temperatures: readonly number[] = [20, 21, 22] as const;\n *\n * const increased = Arr.toUpdated(temperatures, 1, (value) => value + 5);\n *\n * const incrementLast = Arr.toUpdated<number>(\n * 2,\n * (value) => value + 1,\n * )(temperatures);\n *\n * assert.deepStrictEqual(increased, [20, 26, 22]);\n *\n * assert.deepStrictEqual(incrementLast, [20, 21, 23]);\n * ```\n */\nexport function toUpdated<\n const Ar extends readonly unknown[],\n const V = Ar[number],\n>(\n array: Ar,\n index: ArgArrayIndex<Ar>,\n updater: (prev: Ar[number]) => V,\n): IsFixedLengthList<Ar> extends true\n ? Readonly<{ [K in keyof Ar]: Ar[K] | V }>\n : Ar extends NonEmptyTuple<unknown>\n ? NonEmptyArray<Ar[number] | V>\n : readonly (Ar[number] | V)[];\n\n// curried version\nexport function toUpdated<E, const V = E>(\n index: SizeType.ArgArr,\n updater: (prev: E) => V,\n): <const Ar extends readonly E[]>(\n array: Ar,\n) => IsFixedLengthList<Ar> extends true\n ? Readonly<{ [K in keyof Ar]: Ar[K] | V }>\n : Ar extends NonEmptyTuple<unknown>\n ? NonEmptyArray<Ar[number] | V>\n : readonly (Ar[number] | V)[];\n\nexport function toUpdated<E, V = E>(\n ...args:\n | readonly [\n array: readonly E[],\n index: SizeType.ArgArr,\n updater: (prev: E) => V,\n ]\n | readonly [index: SizeType.ArgArr, updater: (prev: E) => V]\n): readonly (E | V)[] | ((array: readonly E[]) => readonly (E | V)[]) {\n switch (args.length) {\n case 3: {\n const [array, index, updater] = args;\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return (array as readonly (E | V)[]).with(index, updater(array[index]!));\n }\n\n case 2: {\n const [index, updater] = args;\n\n return (array) => toUpdated(array, index, updater);\n }\n }\n}\n\n/**\n * Returns a new array with a value inserted at the specified index.\n *\n * @example\n *\n * ```ts\n * const numbers = [1, 2, 4] as const;\n *\n * const withThree = Arr.toInserted(numbers, 2, 3);\n *\n * const appendFive = Arr.toInserted(3, 5)(numbers);\n *\n * assert.deepStrictEqual(withThree, [1, 2, 3, 4]);\n *\n * assert.deepStrictEqual(appendFive, [1, 2, 4, 5]);\n * ```\n */\nexport function toInserted<\n const Ar extends readonly unknown[],\n const V = Ar[number],\n>(\n array: Ar,\n index: ArgArrayIndexWithNegative<Ar>,\n newValue: V,\n): IsFixedLengthList<Ar> extends true\n ? FixedLengthTuple<CastToNumber<Increment<Ar['length']>>, Ar[number] | V>\n : NonEmptyArray<Ar[number] | V>;\n\n// curried version\nexport function toInserted<const V>(\n index: SizeType.ArgArrWithNegative,\n newValue: V,\n): <const Ar extends readonly unknown[]>(\n array: Ar,\n) => IsFixedLengthList<Ar> extends true\n ? FixedLengthTuple<CastToNumber<Increment<Ar['length']>>, Ar[number] | V>\n : NonEmptyArray<Ar[number] | V>;\n\nexport function toInserted<E, const V = E>(\n ...args:\n | readonly [\n array: readonly E[],\n index: SizeType.ArgArrWithNegative,\n newValue: V,\n ]\n | readonly [index: SizeType.ArgArrWithNegative, newValue: V]\n): NonEmptyArray<E | V> | ((array: readonly E[]) => NonEmptyArray<E | V>) {\n switch (args.length) {\n case 3: {\n const [array, index, newValue] = args;\n\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n return (array as readonly (E | V)[]).toSpliced(\n index,\n 0,\n newValue,\n ) as unknown as NonEmptyArray<E | V>;\n }\n\n case 2: {\n const [index, newValue] = args;\n\n return (array) => toInserted(array, index, newValue);\n }\n }\n}\n\ntype CastToNumber<T> = T extends number ? T : never;\n\n/**\n * Returns a new array with the element at the specified index removed.\n *\n * @example\n *\n * ```ts\n * const letters = ['a', 'b', 'c', 'd'] as const;\n *\n * const withoutSecond = Arr.toRemoved(letters, 1);\n *\n * const withoutFirstCurried = Arr.toRemoved(0)(letters);\n *\n * assert.deepStrictEqual(withoutSecond, ['a', 'c', 'd']);\n *\n * assert.deepStrictEqual(withoutFirstCurried, ['b', 'c', 'd']);\n * ```\n */\nexport function toRemoved<const Ar extends readonly unknown[]>(\n array: Ar,\n index: ArgArrayIndexWithNegative<Ar>,\n): readonly Ar[number][];\n\nexport function toRemoved(\n index: SizeType.ArgArrWithNegative,\n): <E>(array: readonly E[]) => readonly E[];\n\nexport function toRemoved<E>(\n ...args:\n | readonly [array: readonly E[], index: SizeType.ArgArrWithNegative]\n | readonly [index: SizeType.ArgArrWithNegative]\n): readonly E[] | ((array: readonly E[]) => readonly E[]) {\n switch (args.length) {\n case 2: {\n const [array, index] = args;\n\n return array.toSpliced(index, 1);\n }\n\n case 1: {\n const [index] = args;\n\n return (array) => toRemoved(array, index);\n }\n }\n}\n\n/**\n * Returns a new array with a value appended to the end.\n *\n * @example\n *\n * ```ts\n * const base = [1, 2] as const;\n *\n * const appended = Arr.toPushed(base, 3);\n *\n * const appendedCurried = Arr.toPushed(4)(base);\n *\n * // The result is guaranteed non-empty, so it is assignable to NonEmptyArray.\n * const nonEmpty: NonEmptyArray<number> = appended;\n *\n * assert.deepStrictEqual<readonly number[]>(appended, [1, 2, 3]);\n *\n * assert.deepStrictEqual<readonly number[]>(appendedCurried, [1, 2, 4]);\n *\n * assert.isTrue(nonEmpty.length >= 1);\n * ```\n */\nexport function toPushed<const Ar extends readonly unknown[], const V>(\n array: Ar,\n newValue: V,\n): readonly [...Ar, V] & NonEmptyArray<Ar[number] | V>;\n\nexport function toPushed<const V>(\n newValue: V,\n): <const Ar extends readonly unknown[]>(\n array: Ar,\n) => readonly [...Ar, V] & NonEmptyArray<Ar[number] | V>;\n\nexport function toPushed<const Ar extends readonly unknown[], const V>(\n ...args: readonly [array: Ar, newValue: V] | readonly [newValue: V]\n): readonly [...Ar, V] | ((array: Ar) => readonly [...Ar, V]) {\n switch (args.length) {\n case 2: {\n const [array, newValue] = args;\n\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n return array.toSpliced(array.length, 0, newValue) as unknown as readonly [\n ...Ar,\n V,\n ];\n }\n\n case 1: {\n const [newValue] = args;\n\n return (array) => toPushed(array, newValue);\n }\n }\n}\n\n/**\n * Returns a new array with a value prepended to the beginning.\n *\n * @example\n *\n * ```ts\n * const base = [2, 3] as const;\n *\n * const prefixed = Arr.toUnshifted(base, 1);\n *\n * const prefixedCurried = Arr.toUnshifted(0)(base);\n *\n * // The result is guaranteed non-empty, so it is assignable to NonEmptyArray.\n * const nonEmpty: NonEmptyArray<number> = prefixed;\n *\n * assert.deepStrictEqual<readonly number[]>(prefixed, [1, 2, 3]);\n *\n * assert.deepStrictEqual<readonly number[]>(prefixedCurried, [0, 2, 3]);\n *\n * assert.isTrue(nonEmpty.length >= 1);\n * ```\n */\nexport function toUnshifted<const Ar extends readonly unknown[], const V>(\n array: Ar,\n newValue: V,\n): readonly [V, ...Ar] & NonEmptyArray<V | Ar[number]>;\n\nexport function toUnshifted<const V>(\n newValue: V,\n): <const Ar extends readonly unknown[]>(\n array: Ar,\n) => readonly [V, ...Ar] & NonEmptyArray<V | Ar[number]>;\n\nexport function toUnshifted<Ar extends readonly unknown[], const V>(\n ...args: readonly [array: Ar, newValue: V] | readonly [newValue: V]\n): readonly [V, ...Ar] | ((array: Ar) => readonly [V, ...Ar]) {\n switch (args.length) {\n case 2: {\n const [array, newValue] = args;\n\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n return array.toSpliced(0, 0, newValue) as unknown as readonly [V, ...Ar];\n }\n\n case 1: {\n const [newValue] = args;\n\n return (array) => toUnshifted(array, newValue);\n }\n }\n}\n\n/**\n * Returns a new array with all elements replaced by the specified value.\n *\n * @example\n *\n * ```ts\n * const base = [1, 2, 3] as const;\n *\n * const filled = Arr.toFilled(base, 0);\n *\n * const filledCurried = Arr.toFilled('x')(base);\n *\n * assert.deepStrictEqual(filled, [0, 0, 0]);\n *\n * assert.deepStrictEqual(filledCurried, ['x', 'x', 'x']);\n * ```\n */\nexport function toFilled<const Ar extends readonly unknown[], const V>(\n array: Ar,\n value: V,\n): IsFixedLengthList<Ar> extends true\n ? FixedLengthTuple<Ar['length'], V>\n : Ar extends NonEmptyTuple<unknown>\n ? NonEmptyArray<V>\n : readonly V[];\n\n// curried version\nexport function toFilled<const V>(\n value: V,\n): <const Ar extends readonly unknown[]>(\n array: Ar,\n) => IsFixedLengthList<Ar> extends true\n ? FixedLengthTuple<Ar['length'], V>\n : Ar extends NonEmptyTuple<unknown>\n ? NonEmptyArray<V>\n : readonly V[];\n\nexport function toFilled<E>(\n ...args: readonly [array: readonly E[], value: E] | readonly [value: E]\n): readonly E[] | ((array: readonly E[]) => readonly E[]) {\n switch (args.length) {\n case 2: {\n const [array, value] = args;\n\n return create(asPositiveUint32(array.length), value);\n }\n\n case 1: {\n const [value] = args;\n\n return (array) => toFilled(array, value);\n }\n }\n}\n\n/**\n * Returns a new array with elements in the specified range replaced by the specified value.\n *\n * @example\n *\n * ```ts\n * const base = [0, 1, 2, 3, 4] as const;\n *\n * const filledMiddle = Arr.toRangeFilled(base, 9, [1, 4]);\n *\n * const filledPrefix = Arr.toRangeFilled(8, [0, 2])(base);\n *\n * assert.deepStrictEqual(filledMiddle, [0, 9, 9, 9, 4]);\n *\n * assert.deepStrictEqual(filledPrefix, [8, 8, 2, 3, 4]);\n * ```\n */\nexport function toRangeFilled<const Ar extends readonly unknown[], const V>(\n array: Ar,\n value: V,\n fillRange: readonly [\n start: ArgArrayIndexWithNegative<Ar>,\n end: ArgArrayIndexWithNegative<Ar>,\n ],\n): IsFixedLengthList<Ar> extends true\n ? FixedLengthTuple<Ar['length'], V | Ar[number]>\n : Ar extends NonEmptyTuple<unknown>\n ? NonEmptyArray<V | Ar[number]>\n : readonly (V | Ar[number])[];\n\n// curried version\nexport function toRangeFilled<const V>(\n value: V,\n fillRange: readonly [\n start: SizeType.ArgArrWithNegative,\n end: SizeType.ArgArrWithNegative,\n ],\n): <const Ar extends readonly unknown[]>(\n array: Ar,\n) => IsFixedLengthList<Ar> extends true\n ? FixedLengthTuple<Ar['length'], V | Ar[number]>\n : Ar extends NonEmptyTuple<unknown>\n ? NonEmptyArray<V | Ar[number]>\n : readonly (V | Ar[number])[];\n\nexport function toRangeFilled<E, const V>(\n ...args:\n | readonly [\n array: readonly E[],\n value: V,\n fillRange: readonly [\n start: SizeType.ArgArrWithNegative,\n end: SizeType.ArgArrWithNegative,\n ],\n ]\n | readonly [\n value: V,\n fillRange: readonly [\n start: SizeType.ArgArrWithNegative,\n end: SizeType.ArgArrWithNegative,\n ],\n ]\n): readonly (E | V)[] | ((array: readonly E[]) => readonly (E | V)[]) {\n switch (args.length) {\n case 3: {\n const [array, value, [start, end]] = args;\n\n const mut_cp: (E | V)[] = castMutable(copy(array));\n\n mut_cp.fill(value, start, end);\n\n return mut_cp;\n }\n\n case 2: {\n const [value, fillRange] = args;\n\n return (array) => toRangeFilled(array, value, fillRange);\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDO,SAAS,OACX,IAAA,EAGiE;AACpE,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,KAAA,EAAO,KAAA,EAAO,QAAQ,CAAA,GAAI,IAAA;AAEjC,MAAA,OAAQ,KAAA,CAA6B,IAAA,CAAK,KAAA,EAAO,QAAQ,CAAA;AAAA,IAC3D;AAAA,IAEA,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,IAAA;AAE1B,MAAA,OAAO,CAAC,KAAA,KAAU,GAAA,CAAI,KAAA,EAAO,OAAO,QAAQ,CAAA;AAAA,IAC9C;AAAA;AAEJ;AA+CO,SAAS,aACX,IAAA,EAOiE;AACpE,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,KAAA,EAAO,KAAA,EAAO,OAAO,CAAA,GAAI,IAAA;AAGhC,MAAA,OAAQ,MAA6B,IAAA,CAAK,KAAA,EAAO,QAAQ,KAAA,CAAM,KAAK,CAAE,CAAC,CAAA;AAAA,IACzE;AAAA,IAEA,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,KAAA,EAAO,OAAO,CAAA,GAAI,IAAA;AAEzB,MAAA,OAAO,CAAC,KAAA,KAAU,SAAA,CAAU,KAAA,EAAO,OAAO,OAAO,CAAA;AAAA,IACnD;AAAA;AAEJ;AAwCO,SAAS,cACX,IAAA,EAOqE;AACxE,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,KAAA,EAAO,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EAAO,SAAS,CAAA,GAAI,IAAA;AAE3B,MAAA,OAAO,CAAC,KAAA,KAAU,aAAA,CAAc,KAAA,EAAO,OAAO,SAAS,CAAA;AAAA,IACzD;AAAA;AAEJ;;;;"}
@@ -305,6 +305,10 @@ export declare function partition<N extends WithSmallInt<PositiveInt & SizeType.
305
305
  /**
306
306
  * Concatenates two arrays.
307
307
  *
308
+ * The exact tuple shape is preserved. Additionally, when either input is known
309
+ * to be non-empty (a non-empty tuple or a branded `NonEmptyArray`), the result
310
+ * is branded as non-empty so it is assignable to `NonEmptyArray`.
311
+ *
308
312
  * @example
309
313
  *
310
314
  * ```ts
@@ -314,12 +318,28 @@ export declare function partition<N extends WithSmallInt<PositiveInt & SizeType.
314
318
  *
315
319
  * const combined = Arr.concat(numbers, words);
316
320
  *
321
+ * // Because at least one input is non-empty, the result is assignable to
322
+ * // NonEmptyArray.
323
+ * const nonEmpty: NonEmptyArray<number | string> = combined;
324
+ *
317
325
  * const expectedCombined = [1, 2, 'three', 'four'] as const;
318
326
  *
319
- * assert.deepStrictEqual(combined, expectedCombined);
327
+ * assert.deepStrictEqual<readonly (number | string)[]>(
328
+ * combined,
329
+ * expectedCombined,
330
+ * );
331
+ *
332
+ * assert.isTrue(nonEmpty.length >= 1);
320
333
  * ```
321
334
  */
322
- export declare const concat: <const Ar1 extends readonly unknown[], const Ar2 extends readonly unknown[]>(array1: Ar1, array2: Ar2) => readonly [...Ar1, ...Ar2];
335
+ export declare const concat: <const Ar1 extends readonly unknown[], const Ar2 extends readonly unknown[]>(array1: Ar1, array2: Ar2) => ConcatResult<Ar1, Ar2>;
336
+ /**
337
+ * Return type of {@link concat}: the concatenated tuple `readonly [...Ar1,
338
+ * ...Ar2]`, additionally branded as {@link NonEmptyArray} when either input is
339
+ * a non-empty tuple (a plain non-empty tuple or a branded `NonEmptyArray`,
340
+ * both of which extend `NonEmptyTuple<unknown>`).
341
+ */
342
+ type ConcatResult<Ar1 extends readonly unknown[], Ar2 extends readonly unknown[]> = Ar1 extends NonEmptyTuple<unknown> ? readonly [...Ar1, ...Ar2] & NonEmptyArray<Ar1[number] | Ar2[number]> : Ar2 extends NonEmptyTuple<unknown> ? readonly [...Ar1, ...Ar2] & NonEmptyArray<Ar1[number] | Ar2[number]> : readonly [...Ar1, ...Ar2];
323
343
  /**
324
344
  * Groups elements by a key derived from each element.
325
345
  *
@@ -412,4 +432,5 @@ export declare const chunk: typeof partition;
412
432
  * ```
413
433
  */
414
434
  export declare const cartesianProduct: <T>(arrays: readonly (readonly T[])[]) => readonly (readonly T[])[];
435
+ export {};
415
436
  //# sourceMappingURL=array-utils-transformation.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"array-utils-transformation.d.mts","sourceRoot":"","sources":["../../../src/array/impl/array-utils-transformation.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,IAAI,EACT,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,WAAW,EAEhB,KAAK,SAAS,EACd,KAAK,oBAAoB,EACzB,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAInD,OAAO,EACL,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,QAAQ,EACd,MAAM,iBAAiB,CAAC;AAKzB;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,GAAG,CAAC,KAAK,CAAC,EAAE,SAAS,SAAS,OAAO,EAAE,EAAE,CAAC,EACxD,KAAK,EAAE,EAAE,EACT,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,CAAC,KAAK,CAAC,GACjD,QAAQ,CAAC;KAAG,CAAC,IAAI,MAAM,EAAE,GAAG,CAAC;CAAE,CAAC,CAAC;AAGpC,wBAAgB,GAAG,CAAC,CAAC,EAAE,CAAC,EACtB,KAA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,OAAO,EAAE,EACpC,KAAK,CAAC,GAAG,SAAS,SAAS,OAAO,EAAE,UAE5B,GAAG,UACH,GAAG,KACV,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAMgB,CAAC;AAErC;;;;GAIG;AACH,eAAO,MAAM,KAAK,kBAAY,CAAC;AAE/B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,UACxB,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,KAChC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,EAWzB,CAAC"}
1
+ {"version":3,"file":"array-utils-transformation.d.mts","sourceRoot":"","sources":["../../../src/array/impl/array-utils-transformation.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,IAAI,EACT,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,WAAW,EAEhB,KAAK,SAAS,EACd,KAAK,oBAAoB,EACzB,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAInD,OAAO,EACL,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,QAAQ,EACd,MAAM,iBAAiB,CAAC;AAKzB;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,GAAG,CAAC,KAAK,CAAC,EAAE,SAAS,SAAS,OAAO,EAAE,EAAE,CAAC,EACxD,KAAK,EAAE,EAAE,EACT,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,CAAC,KAAK,CAAC,GACjD,QAAQ,CAAC;KAAG,CAAC,IAAI,MAAM,EAAE,GAAG,CAAC;CAAE,CAAC,CAAC;AAGpC,wBAAgB,GAAG,CAAC,CAAC,EAAE,CAAC,EACtB,KAAK,EAAE,CAAC,CAAC,EAAE,CAA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AM,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,CAAC,KAAK,CAAC,GACvD,IAAI,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAElC,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,SAAS,aAAa,EAChD,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,GAC5C,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;AAwClD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,GAAG,GACd,KAAK,CAAC,GAAG,SAAS,SAAS,OAAO,EAAE,EACpC,KAAK,CAAC,GAAG,SAAS,SAAS,OAAO,EAAE,UAE5B,GAAG,UACH,GAAG,KACV,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAMgB,CAAC;AAErC;;;;GAIG;AACH,eAAO,MAAM,KAAK,kBAAY,CAAC;AAE/B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,UACxB,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,KAChC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,EAWzB,CAAC"}
@@ -187,7 +187,10 @@ function partition(...args) {
187
187
  }
188
188
  }
189
189
  }
190
- const concat = (array1, array2) => [...array1, ...array2];
190
+ const concat = (array1, array2) => (
191
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
192
+ [...array1, ...array2]
193
+ );
191
194
  function groupBy(...args) {
192
195
  switch (args.length) {
193
196
  case 2: {