@ts-fns/stdlib 0.1.0 → 0.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.
- package/dist/array/index.cjs +230 -33
- package/dist/array/index.cjs.map +1 -1
- package/dist/array/index.d.cts +434 -32
- package/dist/array/index.d.cts.map +1 -1
- package/dist/array/index.d.mts +434 -32
- package/dist/array/index.d.mts.map +1 -1
- package/dist/array/index.mjs +216 -18
- package/dist/array/index.mjs.map +1 -1
- package/dist/function/index.cjs +4 -2
- package/dist/function/index.d.cts +128 -13
- package/dist/function/index.d.cts.map +1 -1
- package/dist/function/index.d.mts +128 -13
- package/dist/function/index.d.mts.map +1 -1
- package/dist/function/index.mjs +3 -3
- package/dist/{function-DnI2v0p3.mjs → function-CYHPhQCQ.mjs} +84 -6
- package/dist/function-CYHPhQCQ.mjs.map +1 -0
- package/dist/{function-CB82a2GS.cjs → function-DYPifnmg.cjs} +95 -5
- package/dist/function-DYPifnmg.cjs.map +1 -0
- package/dist/{get-yrs1Kqho.cjs → get-1kqkxPFX.cjs} +20 -8
- package/dist/get-1kqkxPFX.cjs.map +1 -0
- package/dist/{get-CWL_cu6G.mjs → get-Dv6ejLZg.mjs} +21 -3
- package/dist/get-Dv6ejLZg.mjs.map +1 -0
- package/dist/guard/index.cjs +5 -12
- package/dist/guard/index.cjs.map +1 -1
- package/dist/guard/index.d.cts +18 -17
- package/dist/guard/index.d.cts.map +1 -1
- package/dist/guard/index.d.mts +18 -17
- package/dist/guard/index.d.mts.map +1 -1
- package/dist/guard/index.mjs +4 -12
- package/dist/guard/index.mjs.map +1 -1
- package/dist/index-MbdqaUt1.d.cts +54 -0
- package/dist/index-MbdqaUt1.d.cts.map +1 -0
- package/dist/index-k-paNOu4.d.mts +54 -0
- package/dist/index-k-paNOu4.d.mts.map +1 -0
- package/dist/iterator/index.cjs +72 -26
- package/dist/iterator/index.cjs.map +1 -1
- package/dist/iterator/index.d.cts +157 -5
- package/dist/iterator/index.d.cts.map +1 -1
- package/dist/iterator/index.d.mts +157 -5
- package/dist/iterator/index.d.mts.map +1 -1
- package/dist/iterator/index.mjs +66 -24
- package/dist/iterator/index.mjs.map +1 -1
- package/dist/lens/index.cjs +3 -3
- package/dist/lens/index.cjs.map +1 -1
- package/dist/lens/index.mjs +3 -3
- package/dist/lens/index.mjs.map +1 -1
- package/dist/map/index.cjs +88 -1
- package/dist/map/index.cjs.map +1 -1
- package/dist/map/index.d.cts +130 -2
- package/dist/map/index.d.cts.map +1 -1
- package/dist/map/index.d.mts +130 -2
- package/dist/map/index.d.mts.map +1 -1
- package/dist/map/index.mjs +86 -2
- package/dist/map/index.mjs.map +1 -1
- package/dist/number/index.cjs +91 -18
- package/dist/number/index.cjs.map +1 -1
- package/dist/number/index.d.cts +134 -19
- package/dist/number/index.d.cts.map +1 -1
- package/dist/number/index.d.mts +134 -19
- package/dist/number/index.d.mts.map +1 -1
- package/dist/number/index.mjs +91 -18
- package/dist/number/index.mjs.map +1 -1
- package/dist/object/index.cjs +111 -7
- package/dist/object/index.cjs.map +1 -1
- package/dist/object/index.d.cts +186 -26
- package/dist/object/index.d.cts.map +1 -1
- package/dist/object/index.d.mts +186 -26
- package/dist/object/index.d.mts.map +1 -1
- package/dist/object/index.mjs +111 -7
- package/dist/object/index.mjs.map +1 -1
- package/dist/orNull-CJNrTjhQ.cjs +45 -0
- package/dist/orNull-CJNrTjhQ.cjs.map +1 -0
- package/dist/orNull-EeXiCxD4.mjs +34 -0
- package/dist/orNull-EeXiCxD4.mjs.map +1 -0
- package/dist/order/index.cjs +22 -1
- package/dist/order/index.cjs.map +1 -1
- package/dist/order/index.d.cts +2 -2
- package/dist/order/index.d.mts +2 -2
- package/dist/order/index.mjs +22 -1
- package/dist/order/index.mjs.map +1 -1
- package/dist/{order.constants-BWSCg3C7.d.cts → order.constants-DpGY-EDp.d.cts} +4 -1
- package/dist/order.constants-DpGY-EDp.d.cts.map +1 -0
- package/dist/{order.constants-BWSCg3C7.d.mts → order.constants-DpGY-EDp.d.mts} +4 -1
- package/dist/order.constants-DpGY-EDp.d.mts.map +1 -0
- package/dist/purry-DXnhXie9.mjs +22 -0
- package/dist/purry-DXnhXie9.mjs.map +1 -0
- package/dist/purry-Dqp_F64t.cjs +27 -0
- package/dist/purry-Dqp_F64t.cjs.map +1 -0
- package/dist/set/index.cjs +59 -1
- package/dist/set/index.cjs.map +1 -1
- package/dist/set/index.d.cts +151 -2
- package/dist/set/index.d.cts.map +1 -1
- package/dist/set/index.d.mts +151 -2
- package/dist/set/index.d.mts.map +1 -1
- package/dist/set/index.mjs +59 -2
- package/dist/set/index.mjs.map +1 -1
- package/dist/string/index.cjs +289 -15
- package/dist/string/index.cjs.map +1 -1
- package/dist/string/index.d.cts +406 -1
- package/dist/string/index.d.cts.map +1 -1
- package/dist/string/index.d.mts +406 -1
- package/dist/string/index.d.mts.map +1 -1
- package/dist/string/index.mjs +271 -4
- package/dist/string/index.mjs.map +1 -1
- package/dist/tuple/index.cjs +20 -21
- package/dist/tuple/index.cjs.map +1 -1
- package/dist/tuple/index.d.cts +27 -58
- package/dist/tuple/index.d.cts.map +1 -1
- package/dist/tuple/index.d.mts +27 -58
- package/dist/tuple/index.d.mts.map +1 -1
- package/dist/tuple/index.mjs +20 -22
- package/dist/tuple/index.mjs.map +1 -1
- package/package.json +5 -6
- package/dist/function-CB82a2GS.cjs.map +0 -1
- package/dist/function-DnI2v0p3.mjs.map +0 -1
- package/dist/get-CWL_cu6G.mjs.map +0 -1
- package/dist/get-yrs1Kqho.cjs.map +0 -1
- package/dist/index-BJlKyBJH.d.cts +0 -18
- package/dist/index-BJlKyBJH.d.cts.map +0 -1
- package/dist/index-DGrnGMDt.d.mts +0 -18
- package/dist/index-DGrnGMDt.d.mts.map +0 -1
- package/dist/isNotNil-DrF-ohem.cjs +0 -28
- package/dist/isNotNil-DrF-ohem.cjs.map +0 -1
- package/dist/isNotNil-R5f1hC53.mjs +0 -23
- package/dist/isNotNil-R5f1hC53.mjs.map +0 -1
- package/dist/orThrow-V91Jw2lF.mjs +0 -15
- package/dist/orThrow-V91Jw2lF.mjs.map +0 -1
- package/dist/orThrow-ejzcQYAI.cjs +0 -20
- package/dist/orThrow-ejzcQYAI.cjs.map +0 -1
- package/dist/order.constants-BWSCg3C7.d.cts.map +0 -1
- package/dist/order.constants-BWSCg3C7.d.mts.map +0 -1
- package/dist/purry-B2_0DGLV.cjs +0 -28
- package/dist/purry-B2_0DGLV.cjs.map +0 -1
- package/dist/purry-BOWmqwDB.mjs +0 -23
- package/dist/purry-BOWmqwDB.mjs.map +0 -1
package/dist/array/index.d.mts
CHANGED
|
@@ -1,30 +1,52 @@
|
|
|
1
1
|
import { r as NotFoundError, t as EmptyArrayError } from "../errors-CJsLpYo9.mjs";
|
|
2
2
|
import { a as NonEmptyArray, s as ReadonlyNonEmptyArray } from "../types-D8f67ZCe.mjs";
|
|
3
|
-
import { i as Order } from "../order.constants-
|
|
3
|
+
import { i as Order } from "../order.constants-DpGY-EDp.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/array/_globalAliases.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Creates an array from an iterable or array-like object.
|
|
8
|
+
* @function
|
|
9
|
+
*/
|
|
6
10
|
declare const from: {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
<T>(arrayLike: ArrayLike<T>): T[];
|
|
12
|
+
<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
|
13
|
+
<T>(iterable: Iterable<T> | ArrayLike<T>): T[];
|
|
14
|
+
<T, U>(iterable: Iterable<T> | ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Creates an array from an async iterable.
|
|
18
|
+
* @function
|
|
19
|
+
*/
|
|
20
|
+
declare const fromAsync: {
|
|
21
|
+
<T>(iterableOrArrayLike: AsyncIterable<T> | Iterable<T | PromiseLike<T>> | ArrayLike<T | PromiseLike<T>>): Promise<T[]>;
|
|
22
|
+
<T, U>(iterableOrArrayLike: AsyncIterable<T> | Iterable<T> | ArrayLike<T>, mapFn: (value: Awaited<T>, index: number) => U, thisArg?: any): Promise<Awaited<U>[]>;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Checks whether a value is an array.
|
|
26
|
+
* @function
|
|
27
|
+
*/
|
|
28
|
+
declare const isArray: (arg: any) => arg is any[];
|
|
29
|
+
/**
|
|
30
|
+
* Creates an array containing the given values.
|
|
31
|
+
* @function
|
|
32
|
+
*/
|
|
33
|
+
declare const of: <T>(...items: T[]) => T[];
|
|
34
|
+
/**
|
|
35
|
+
* Alias of the built-in array constructor. `new Array() === new Arr.Ctor()
|
|
36
|
+
* @function
|
|
37
|
+
*/
|
|
38
|
+
declare const Ctor: ArrayConstructor;
|
|
16
39
|
//#endregion
|
|
17
40
|
//#region src/array/at.d.ts
|
|
18
41
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @category Array
|
|
22
|
-
* @param arr - The array to get the element from.
|
|
23
|
-
* @param index - The index of the element to get.
|
|
42
|
+
* Gets an element from an array by index, including negative indices from the end.
|
|
43
|
+
* Returns a range error when the array is empty or the index is out of bounds.
|
|
24
44
|
*
|
|
25
45
|
* @example
|
|
26
46
|
* ```ts
|
|
27
47
|
* at([1, 2, 3], 1); // 2
|
|
48
|
+
* at(-1)([1, 2, 3]); // 3
|
|
49
|
+
* at([1, 2, 3], 3); // RangeError
|
|
28
50
|
* ```
|
|
29
51
|
*/
|
|
30
52
|
declare function at<T>(index: number): (arr: readonly T[]) => RangeError | T;
|
|
@@ -37,8 +59,14 @@ declare function atAssert<T>(arr: readonly T[], index: number): T;
|
|
|
37
59
|
//#endregion
|
|
38
60
|
//#region src/array/chunk.d.ts
|
|
39
61
|
/**
|
|
62
|
+
* Splits an array into consecutive groups of the given size.
|
|
63
|
+
* The last chunk may contain fewer elements when the length is not evenly divisible.
|
|
40
64
|
*
|
|
41
|
-
* @
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
|
|
68
|
+
* chunk(2)([1, 2, 3, 4, 5]); // [[1, 2], [3, 4], [5]]
|
|
69
|
+
* ```
|
|
42
70
|
*/
|
|
43
71
|
declare function chunk(size: number): <T>(arr: readonly T[]) => T[][];
|
|
44
72
|
declare function chunk<T>(arr: readonly T[], size: number): T[][];
|
|
@@ -49,20 +77,58 @@ declare function chunkAssert<T>(size: number): (arr: readonly T[]) => T[][];
|
|
|
49
77
|
declare function chunkAssert<T>(arr: readonly T[], size: number): T[][];
|
|
50
78
|
//#endregion
|
|
51
79
|
//#region src/array/concat.d.ts
|
|
80
|
+
/**
|
|
81
|
+
* Concatenates two arrays without mutating either input.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* concat([1, 2], [3, 4]); // [1, 2, 3, 4]
|
|
86
|
+
* concat([3, 4])([1, 2]); // [1, 2, 3, 4]
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
52
89
|
declare function concat<T>(other: readonly T[]): (arr: readonly T[]) => T;
|
|
53
90
|
declare function concat<T>(arr: readonly T[], other: readonly T[]): T;
|
|
54
91
|
//#endregion
|
|
55
92
|
//#region src/array/drop.d.ts
|
|
93
|
+
/**
|
|
94
|
+
* Drops the first `n` elements from an array.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* drop([1, 2, 3, 4], 2); // [3, 4]
|
|
99
|
+
* drop(2)([1, 2, 3, 4]); // [3, 4]
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
56
102
|
declare function drop<T>(n: number): (arr: readonly T[]) => T[];
|
|
57
103
|
declare function drop<T>(arr: readonly T[], n: number): T[];
|
|
58
104
|
//#endregion
|
|
59
105
|
//#region src/array/every.d.ts
|
|
106
|
+
/**
|
|
107
|
+
* Tests whether every element satisfies a predicate.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```ts
|
|
111
|
+
* every([2, 4, 6], n => n % 2 === 0); // true
|
|
112
|
+
* every(n => n > 0)([1, 2, 3]); // true
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
60
115
|
declare function every<T, S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S): (arr: readonly T[]) => arr is S[];
|
|
61
116
|
declare function every<T>(predicate: (value: T, index: number, array: readonly T[]) => boolean): (arr: readonly T[]) => T[];
|
|
62
117
|
declare function every<T, S extends T>(arr: readonly T[], predicate: (value: T, index: number, array: readonly T[]) => value is S): arr is S[];
|
|
63
118
|
declare function every<T>(arr: readonly T[], predicate: (value: T, index: number, array: readonly T[]) => boolean): T[];
|
|
64
119
|
//#endregion
|
|
65
120
|
//#region src/array/find.d.ts
|
|
121
|
+
/**
|
|
122
|
+
* Returns the first element that satisfies a predicate.
|
|
123
|
+
* Returns a not-found error when no element matches.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* find([1, 2, 3], n => n > 1); // 2
|
|
128
|
+
* find(n => n > 1)([1, 2, 3]); // 2
|
|
129
|
+
* find([1, 2, 3], n => n > 10); // NotFoundError
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
66
132
|
declare function find<T, S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S): (arr: readonly T[]) => NotFoundError | S;
|
|
67
133
|
declare function find<T>(predicate: (value: T, index: number, array: readonly T[]) => boolean): (arr: readonly T[]) => NotFoundError | T;
|
|
68
134
|
declare function find<T, S extends T>(arr: readonly T[], predicate: (value: T, index: number, array: readonly T[]) => value is S): NotFoundError | S;
|
|
@@ -76,6 +142,17 @@ declare function findAssert<T, S extends T>(arr: readonly T[], predicate: (value
|
|
|
76
142
|
declare function findAssert<T>(arr: readonly T[], predicate: (value: T, index: number, array: readonly T[]) => boolean): T;
|
|
77
143
|
//#endregion
|
|
78
144
|
//#region src/array/findIndex.d.ts
|
|
145
|
+
/**
|
|
146
|
+
* Returns the index of the first element that satisfies a predicate.
|
|
147
|
+
* Returns a not-found error when no element matches.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* findIndex([1, 2, 3], n => n > 1); // 1
|
|
152
|
+
* findIndex(n => n > 1)([1, 2, 3]); // 1
|
|
153
|
+
* findIndex([1, 2, 3], n => n > 10); // NotFoundError
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
79
156
|
declare function findIndex<T>(predicate: (value: T, index: number, array: readonly T[]) => boolean): (arr: readonly T[]) => NotFoundError | number;
|
|
80
157
|
declare function findIndex<T>(arr: readonly T[], predicate: (value: T, index: number, array: readonly T[]) => boolean): NotFoundError | number;
|
|
81
158
|
declare namespace findIndex {
|
|
@@ -85,6 +162,17 @@ declare function findIndexAssert<T>(predicate: (value: T, index: number, array:
|
|
|
85
162
|
declare function findIndexAssert<T>(arr: readonly T[], predicate: (value: T, index: number, array: readonly T[]) => boolean): number;
|
|
86
163
|
//#endregion
|
|
87
164
|
//#region src/array/findLast.d.ts
|
|
165
|
+
/**
|
|
166
|
+
* Returns the last element that satisfies a predicate.
|
|
167
|
+
* Returns a not-found error when no element matches.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* findLast([1, 2, 3, 2], n => n === 2); // 2
|
|
172
|
+
* findLast(n => n === 2)([1, 2, 3, 2]); // 2
|
|
173
|
+
* findLast([1, 2, 3], n => n > 10); // NotFoundError
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
88
176
|
declare function findLast<T, S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S): (arr: readonly T[]) => NotFoundError | S;
|
|
89
177
|
declare function findLast<T>(predicate: (value: T, index: number, array: readonly T[]) => boolean): (arr: readonly T[]) => NotFoundError | T;
|
|
90
178
|
declare function findLast<T, S extends T>(arr: readonly T[], predicate: (value: T, index: number, array: readonly T[]) => value is S): NotFoundError | S;
|
|
@@ -96,6 +184,17 @@ declare function findLastAssert<T>(predicate: (value: T, index: number, array: r
|
|
|
96
184
|
declare function findLastAssert<T>(arr: readonly T[], predicate: (value: T, index: number, array: readonly T[]) => boolean): T;
|
|
97
185
|
//#endregion
|
|
98
186
|
//#region src/array/findLastIndex.d.ts
|
|
187
|
+
/**
|
|
188
|
+
* Returns the index of the last element that satisfies a predicate.
|
|
189
|
+
* Returns a not-found error when no element matches.
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```ts
|
|
193
|
+
* findLastIndex([1, 2, 3, 2], n => n === 2); // 3
|
|
194
|
+
* findLastIndex(n => n === 2)([1, 2, 3, 2]); // 3
|
|
195
|
+
* findLastIndex([1, 2, 3], n => n > 10); // NotFoundError
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
99
198
|
declare function findLastIndex<T>(predicate: (value: T, index: number, array: readonly T[]) => boolean): (arr: readonly T[]) => NotFoundError | number;
|
|
100
199
|
declare function findLastIndex<T>(arr: readonly T[], predicate: (value: T, index: number, array: readonly T[]) => boolean): NotFoundError | number;
|
|
101
200
|
declare namespace findLastIndex {
|
|
@@ -106,7 +205,14 @@ declare function findLastIndexAssert<T>(arr: readonly T[], predicate: (value: T,
|
|
|
106
205
|
//#endregion
|
|
107
206
|
//#region src/array/first.d.ts
|
|
108
207
|
/**
|
|
208
|
+
* Returns the first element of an array.
|
|
209
|
+
* Returns an empty-array error when the array has no elements.
|
|
109
210
|
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```ts
|
|
213
|
+
* first([1, 2, 3]); // 1
|
|
214
|
+
* first([]); // EmptyArrayError
|
|
215
|
+
* ```
|
|
110
216
|
*/
|
|
111
217
|
declare function first<T>(arr: ReadonlyNonEmptyArray<T>): T[];
|
|
112
218
|
declare function first<T>(arr: readonly T[]): EmptyArrayError | T;
|
|
@@ -116,16 +222,40 @@ declare namespace first {
|
|
|
116
222
|
declare function firstAssert<T>(arr: readonly T[]): T;
|
|
117
223
|
//#endregion
|
|
118
224
|
//#region src/array/flatMap.d.ts
|
|
225
|
+
/**
|
|
226
|
+
* Maps each element to an array and flattens the result by one level.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```ts
|
|
230
|
+
* flatMap([1, 2, 3], n => [n, n * 10]); // [1, 10, 2, 20, 3, 30]
|
|
231
|
+
* flatMap(n => [n, n * 10])([1, 2, 3]); // [1, 10, 2, 20, 3, 30]
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
119
234
|
declare function flatMap<T, U>(callbackfn: (value: T, index: number, array: readonly T[]) => U | readonly U[]): (arr: T[]) => U[];
|
|
120
235
|
declare function flatMap<T, U>(arr: T[], callbackfn: (value: T, index: number, array: readonly U[]) => U[]): U[];
|
|
121
236
|
//#endregion
|
|
122
237
|
//#region src/array/forEach.d.ts
|
|
238
|
+
/**
|
|
239
|
+
* Runs a callback for each element and returns the original array.
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```ts
|
|
243
|
+
* forEach([1, 2, 3], n => console.log(n)); // [1, 2, 3]
|
|
244
|
+
* forEach(n => console.log(n))([1, 2, 3]); // [1, 2, 3]
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
123
247
|
declare function forEach<T>(callbackfn: (value: T, index: number, array: readonly T[]) => void): (arr: T[]) => T[];
|
|
124
248
|
declare function forEach<T>(arr: T[], callbackfn: (value: T, index: number, array: readonly T[]) => void): T[];
|
|
125
249
|
//#endregion
|
|
126
250
|
//#region src/array/init.d.ts
|
|
127
251
|
/**
|
|
252
|
+
* Returns all elements except the last.
|
|
128
253
|
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* init([1, 2, 3]); // [1, 2]
|
|
257
|
+
* init([1]); // []
|
|
258
|
+
* ```
|
|
129
259
|
*/
|
|
130
260
|
declare function init<T>(arr: readonly T[]): T[];
|
|
131
261
|
declare namespace init {
|
|
@@ -135,8 +265,15 @@ declare function initAssert<T>(arr: readonly T[]): T[];
|
|
|
135
265
|
//#endregion
|
|
136
266
|
//#region src/array/insert.d.ts
|
|
137
267
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
268
|
+
* Inserts or replaces the element at the given index without mutating the original array.
|
|
269
|
+
* Named `insert` because `with` is a reserved word.
|
|
270
|
+
* Returns a range error when the index is invalid.
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```ts
|
|
274
|
+
* insert([1, 2, 3], 1, 9); // [1, 9, 3]
|
|
275
|
+
* insert(1, 9)([1, 2, 3]); // [1, 9, 3]
|
|
276
|
+
* ```
|
|
140
277
|
*/
|
|
141
278
|
declare function insert<T>(index: number, value: T): (arr: readonly T[]) => T[];
|
|
142
279
|
declare function insert<T>(arr: readonly T[], index: number, value: T): T[];
|
|
@@ -147,18 +284,52 @@ declare function insertAssert<T>(index: number, value: T): (arr: readonly T[]) =
|
|
|
147
284
|
declare function insertAssert<T>(arr: readonly T[], index: number, value: T): T[];
|
|
148
285
|
//#endregion
|
|
149
286
|
//#region src/array/isEmpty.d.ts
|
|
287
|
+
/**
|
|
288
|
+
* Checks whether an array contains at least one element.
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* ```ts
|
|
292
|
+
* isNotEmpty([1, 2]); // true
|
|
293
|
+
* isNotEmpty([]); // false
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
150
296
|
declare function isNotEmpty<T>(value: T[]): value is NonEmptyArray<T>;
|
|
151
297
|
declare function isNotEmpty<T>(value: readonly T[]): value is ReadonlyNonEmptyArray<T>;
|
|
298
|
+
/**
|
|
299
|
+
* Checks whether an array has no elements.
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```ts
|
|
303
|
+
* isEmpty([]); // true
|
|
304
|
+
* isEmpty([1]); // false
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
152
307
|
declare function isEmpty<T>(value: T[]): value is [];
|
|
153
308
|
declare function isEmpty<T>(value: readonly T[]): value is readonly [];
|
|
154
309
|
//#endregion
|
|
155
310
|
//#region src/array/join.d.ts
|
|
311
|
+
/**
|
|
312
|
+
* Joins string array elements with a separator.
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* ```ts
|
|
316
|
+
* join(['a', 'b', 'c'], '-'); // 'a-b-c'
|
|
317
|
+
* join('-')(['a', 'b', 'c']); // 'a-b-c'
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
156
320
|
declare function join(separator: string): (arr: string[]) => string;
|
|
157
321
|
declare function join(arr: string[], separator: string): string;
|
|
158
322
|
//#endregion
|
|
159
323
|
//#region src/array/last.d.ts
|
|
160
324
|
/**
|
|
325
|
+
* Returns the last element of an array.
|
|
326
|
+
* Returns an empty-array error when the array has no elements.
|
|
161
327
|
*
|
|
328
|
+
* @example
|
|
329
|
+
* ```ts
|
|
330
|
+
* last([1, 2, 3]); // 3
|
|
331
|
+
* last([]); // EmptyArrayError
|
|
332
|
+
* ```
|
|
162
333
|
*/
|
|
163
334
|
declare function last<T>(arr: ReadonlyNonEmptyArray<T>): T;
|
|
164
335
|
declare function last<T>(arr: readonly T[]): EmptyArrayError | T;
|
|
@@ -169,25 +340,52 @@ declare function lastAssert<T>(arr: readonly T[]): T;
|
|
|
169
340
|
//#endregion
|
|
170
341
|
//#region src/array/length.d.ts
|
|
171
342
|
/**
|
|
172
|
-
* Returns
|
|
173
|
-
*
|
|
174
|
-
* @
|
|
343
|
+
* Returns the number of elements in an array.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```ts
|
|
347
|
+
* length([1, 2, 3]); // 3
|
|
348
|
+
* length([]); // 0
|
|
349
|
+
* ```
|
|
175
350
|
*/
|
|
176
351
|
declare function length(arr: readonly unknown[]): number;
|
|
177
352
|
//#endregion
|
|
178
353
|
//#region src/array/map.d.ts
|
|
354
|
+
/**
|
|
355
|
+
* Transforms each element with a callback.
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* ```ts
|
|
359
|
+
* map([1, 2, 3], n => n * 2); // [2, 4, 6]
|
|
360
|
+
* map(n => n * 2)([1, 2, 3]); // [2, 4, 6]
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
179
363
|
declare function map<T, U>(callbackfn: (value: T, index: number, array: readonly T[]) => U): (arr: T[]) => U[];
|
|
180
364
|
declare function map<T, U>(data: T[], callbackfn: (value: T, index: number, array: readonly T[]) => U): U[];
|
|
181
365
|
//#endregion
|
|
182
366
|
//#region src/array/ofLength.d.ts
|
|
183
367
|
/**
|
|
184
|
-
*
|
|
368
|
+
* Creates a sparse array with the given length.
|
|
185
369
|
*
|
|
186
|
-
* @
|
|
370
|
+
* @example
|
|
371
|
+
* ```ts
|
|
372
|
+
* ofLength(3); // [empty × 3]
|
|
373
|
+
* ofLength<string>(2); // [empty × 2]
|
|
374
|
+
* ```
|
|
187
375
|
*/
|
|
188
376
|
declare function ofLength<T = unknown>(arrayLength: number): T[];
|
|
189
377
|
//#endregion
|
|
190
378
|
//#region src/array/partition.d.ts
|
|
379
|
+
/**
|
|
380
|
+
* Splits an array into two groups based on a predicate.
|
|
381
|
+
* The first group contains matching elements; the second contains the rest.
|
|
382
|
+
*
|
|
383
|
+
* @example
|
|
384
|
+
* ```ts
|
|
385
|
+
* partition([1, 2, 3, 4], n => n % 2 === 0); // [[2, 4], [1, 3]]
|
|
386
|
+
* partition(n => n % 2 === 0)([1, 2, 3, 4]); // [[2, 4], [1, 3]]
|
|
387
|
+
* ```
|
|
388
|
+
*/
|
|
191
389
|
declare function partition<T, S extends T>(predicate: (value: T, index: number, arr: readonly T[]) => value is S): (data: readonly T[]) => [S[], T[]];
|
|
192
390
|
declare function partition<T>(predicate: (value: T, index: number, arr: readonly T[]) => boolean): (data: readonly T[]) => [T[], T[]];
|
|
193
391
|
declare function partition<T, S extends T>(data: readonly T[], predicate: (value: T, index: number, arr: readonly T[]) => value is S): [S[], T[]];
|
|
@@ -195,7 +393,14 @@ declare function partition<T>(data: readonly T[], predicate: (value: T, index: n
|
|
|
195
393
|
//#endregion
|
|
196
394
|
//#region src/array/pop.d.ts
|
|
197
395
|
/**
|
|
198
|
-
*
|
|
396
|
+
* Removes and returns the last element along with the remaining array.
|
|
397
|
+
* Returns an empty-array error when the array has no elements.
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* ```ts
|
|
401
|
+
* pop([1, 2, 3]); // [3, [1, 2]]
|
|
402
|
+
* pop([]); // EmptyArrayError
|
|
403
|
+
* ```
|
|
199
404
|
*/
|
|
200
405
|
declare function pop<T>(arr: ReadonlyNonEmptyArray<T>): [T, T[]];
|
|
201
406
|
declare function pop<T>(arr: readonly T[]): EmptyArrayError | [T, T[]];
|
|
@@ -205,48 +410,131 @@ declare namespace pop {
|
|
|
205
410
|
declare function popAssert<T>(arr: readonly T[]): [T, T[]];
|
|
206
411
|
//#endregion
|
|
207
412
|
//#region src/array/prepend.d.ts
|
|
413
|
+
/**
|
|
414
|
+
* Prepends the elements of one array to another without mutating either input.
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* ```ts
|
|
418
|
+
* prepend([3, 4], [1, 2]); // [1, 2, 3, 4]
|
|
419
|
+
* prepend([1, 2])([3, 4]); // [1, 2, 3, 4]
|
|
420
|
+
* ```
|
|
421
|
+
*/
|
|
208
422
|
declare function prepend<T>(other: readonly T[]): (arr: readonly T[]) => T[];
|
|
209
423
|
declare function prepend<T>(arr: readonly T[], other: readonly T[]): T[];
|
|
210
424
|
//#endregion
|
|
211
425
|
//#region src/array/push.d.ts
|
|
426
|
+
/**
|
|
427
|
+
* Appends a value to an array without mutating the original.
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```ts
|
|
431
|
+
* push([1, 2], 3); // [1, 2, 3]
|
|
432
|
+
* push(3)([1, 2]); // [1, 2, 3]
|
|
433
|
+
* ```
|
|
434
|
+
*/
|
|
212
435
|
declare function push<T>(value: T): (arr: readonly T[]) => T[];
|
|
213
436
|
declare function push<T>(arr: readonly T[], value: T): T[];
|
|
214
437
|
//#endregion
|
|
215
438
|
//#region src/array/reduce.d.ts
|
|
439
|
+
/**
|
|
440
|
+
* Reduces an array to a single value using an initial accumulator.
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* ```ts
|
|
444
|
+
* reduce([1, 2, 3], (acc, n) => acc + n, 0); // 6
|
|
445
|
+
* reduce((acc, n) => acc + n, 0)([1, 2, 3]); // 6
|
|
446
|
+
* ```
|
|
447
|
+
*/
|
|
216
448
|
declare function reduce<T, U>(arr: readonly T[], callbackFn: (acc: U, value: T, index: number, array: readonly T[]) => U, initialValue: U): U;
|
|
217
449
|
declare function reduce<T, U>(callbackFn: (acc: U, value: T, index: number, array: readonly T[]) => U, initialValue: U): (arr: readonly T[]) => U;
|
|
218
450
|
//#endregion
|
|
219
451
|
//#region src/array/reduce1.d.ts
|
|
452
|
+
/**
|
|
453
|
+
* Reduces a non-empty array to a single value using the first element as the initial accumulator.
|
|
454
|
+
*
|
|
455
|
+
* @example
|
|
456
|
+
* ```ts
|
|
457
|
+
* reduce1([1, 2, 3], (acc, n) => acc + n); // 6
|
|
458
|
+
* reduce1((acc, n) => acc + n)([1, 2, 3]); // 6
|
|
459
|
+
* ```
|
|
460
|
+
*/
|
|
220
461
|
declare function reduce1<T>(arr: readonly T[], callbackFn: (acc: T, value: T, index: number, array: readonly T[]) => T): T;
|
|
221
462
|
declare function reduce1<T>(callbackFn: (acc: T, value: T, index: number, array: readonly T[]) => T): (arr: readonly T[]) => T;
|
|
222
463
|
//#endregion
|
|
223
464
|
//#region src/array/reduceRight.d.ts
|
|
465
|
+
/**
|
|
466
|
+
* Reduces an array from the right using an initial accumulator.
|
|
467
|
+
*
|
|
468
|
+
* @example
|
|
469
|
+
* ```ts
|
|
470
|
+
* reduceRight([1, 2, 3], (acc, n) => acc - n, 0); // -6
|
|
471
|
+
* reduceRight((acc, n) => acc - n, 0)([1, 2, 3]); // -6
|
|
472
|
+
* ```
|
|
473
|
+
*/
|
|
224
474
|
declare function reduceRight<T, U>(arr: readonly T[], callbackFn: (acc: U, value: T, index: number, array: readonly T[]) => U, initialValue: U): U;
|
|
225
475
|
declare function reduceRight<T, U>(callbackFn: (acc: U, value: T, index: number, array: readonly T[]) => U, initialValue: U): (arr: readonly T[]) => U;
|
|
226
476
|
//#endregion
|
|
227
477
|
//#region src/array/reduceRight1.d.ts
|
|
478
|
+
/**
|
|
479
|
+
* Reduces a non-empty array from the right using the last element as the initial accumulator.
|
|
480
|
+
*
|
|
481
|
+
* @example
|
|
482
|
+
* ```ts
|
|
483
|
+
* reduceRight1([1, 2, 3], (acc, n) => acc - n); // 0
|
|
484
|
+
* reduceRight1((acc, n) => acc - n)([1, 2, 3]); // 0
|
|
485
|
+
* ```
|
|
486
|
+
*/
|
|
228
487
|
declare function reduceRight1<T>(arr: readonly T[], callbackFn: (acc: T, value: T, index: number, array: readonly T[]) => T): T;
|
|
229
488
|
declare function reduceRight1<T>(callbackFn: (acc: T, value: T, index: number, array: readonly T[]) => T): (arr: readonly T[]) => T;
|
|
230
489
|
//#endregion
|
|
231
490
|
//#region src/array/rest.d.ts
|
|
232
491
|
/**
|
|
233
|
-
* Returns
|
|
234
|
-
*
|
|
235
|
-
* @
|
|
492
|
+
* Returns all elements except the first.
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
* ```ts
|
|
496
|
+
* rest([1, 2, 3]); // [2, 3]
|
|
497
|
+
* rest([1]); // []
|
|
498
|
+
* ```
|
|
236
499
|
*/
|
|
237
500
|
declare function rest<T>(arr: readonly T[]): T[];
|
|
238
501
|
//#endregion
|
|
239
502
|
//#region src/array/reverse.d.ts
|
|
503
|
+
/**
|
|
504
|
+
* Returns a reversed copy of an array without mutating the original.
|
|
505
|
+
*
|
|
506
|
+
* @example
|
|
507
|
+
* ```ts
|
|
508
|
+
* reverse([1, 2, 3]); // [3, 2, 1]
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
240
511
|
declare function reverse(index: number): <T>(arr: readonly T[]) => T[];
|
|
241
512
|
declare function reverse<T>(arr: readonly T[], index: number): T[];
|
|
242
513
|
//#endregion
|
|
243
514
|
//#region src/array/scan.d.ts
|
|
515
|
+
/**
|
|
516
|
+
* Returns the intermediate accumulator values produced while reducing an array.
|
|
517
|
+
* The first element is the initial value; each subsequent element is the accumulator after processing one more item.
|
|
518
|
+
*
|
|
519
|
+
* @example
|
|
520
|
+
* ```ts
|
|
521
|
+
* scan([1, 2, 3], (acc, n) => acc + n, 0); // [0, 1, 3, 6]
|
|
522
|
+
* scan((acc, n) => acc + n, 0)([1, 2, 3]); // [0, 1, 3, 6]
|
|
523
|
+
* ```
|
|
524
|
+
*/
|
|
244
525
|
declare function scan<T, U>(callbackFn: (acc: U, value: T, index: number, array: readonly T[]) => U, initialValue: U): (arr: T[]) => U[];
|
|
245
526
|
declare function scan<T, U>(arr: T[], callbackFn: (acc: U, value: T, index: number, array: readonly T[]) => U, initialValue: U): U[];
|
|
246
527
|
//#endregion
|
|
247
528
|
//#region src/array/shift.d.ts
|
|
248
529
|
/**
|
|
530
|
+
* Removes and returns the first element along with the remaining array.
|
|
531
|
+
* Returns an empty-array error when the array has no elements.
|
|
249
532
|
*
|
|
533
|
+
* @example
|
|
534
|
+
* ```ts
|
|
535
|
+
* shift([1, 2, 3]); // [1, [2, 3]]
|
|
536
|
+
* shift([]); // EmptyArrayError
|
|
537
|
+
* ```
|
|
250
538
|
*/
|
|
251
539
|
declare function shift<T>(arr: ReadonlyNonEmptyArray<T>): [T, T[]];
|
|
252
540
|
declare namespace shift {
|
|
@@ -255,51 +543,141 @@ declare namespace shift {
|
|
|
255
543
|
declare function shiftAssert<T>(arr: readonly T[]): [T, T[]];
|
|
256
544
|
//#endregion
|
|
257
545
|
//#region src/array/shuffle.d.ts
|
|
258
|
-
|
|
546
|
+
/**
|
|
547
|
+
* Returns a shuffled copy of an array using the Fisher-Yates algorithm.
|
|
548
|
+
*
|
|
549
|
+
* @example
|
|
550
|
+
* ```ts
|
|
551
|
+
* shuffle([1, 2, 3, 4]); // e.g. [3, 1, 4, 2]
|
|
552
|
+
* ```
|
|
553
|
+
*/
|
|
554
|
+
declare function shuffle<T>(arr: readonly T[]): T[];
|
|
259
555
|
//#endregion
|
|
260
556
|
//#region src/array/some.d.ts
|
|
557
|
+
/**
|
|
558
|
+
* Tests whether at least one element satisfies a predicate.
|
|
559
|
+
*
|
|
560
|
+
* @example
|
|
561
|
+
* ```ts
|
|
562
|
+
* some([1, 2, 3], n => n > 2); // true
|
|
563
|
+
* some(n => n > 2)([1, 2, 3]); // true
|
|
564
|
+
* ```
|
|
565
|
+
*/
|
|
261
566
|
declare function some<T>(predicate: (value: T, index: number, array: readonly T[]) => boolean): (arr: readonly T[]) => T[];
|
|
262
567
|
declare function some<T>(arr: readonly T[], predicate: (value: T, index: number, array: readonly T[]) => boolean): T[];
|
|
263
568
|
//#endregion
|
|
264
569
|
//#region src/array/sort.d.ts
|
|
570
|
+
/**
|
|
571
|
+
* Returns a sorted copy of an array using a comparison function.
|
|
572
|
+
*
|
|
573
|
+
* @example
|
|
574
|
+
* ```ts
|
|
575
|
+
* sort([3, 1, 2], (a, b) => a - b); // [1, 2, 3]
|
|
576
|
+
* sort((a, b) => a - b)([3, 1, 2]); // [1, 2, 3]
|
|
577
|
+
* ```
|
|
578
|
+
*/
|
|
265
579
|
declare function sort<T>(compareFn: (left: T, right: T) => Order): (arr: T[]) => T[];
|
|
266
580
|
declare function sort<T>(arr: T[], compareFn: (left: T, right: T) => Order): T[];
|
|
267
581
|
//#endregion
|
|
268
582
|
//#region src/array/sortBy.d.ts
|
|
583
|
+
/**
|
|
584
|
+
* Returns a sorted copy of an array by mapping each element to a comparable value first.
|
|
585
|
+
*
|
|
586
|
+
* @example
|
|
587
|
+
* ```ts
|
|
588
|
+
* sortBy([{ n: 3 }, { n: 1 }], x => x.n); // [{ n: 1 }, { n: 3 }]
|
|
589
|
+
* sortBy(x => x.n)([{ n: 3 }, { n: 1 }]); // [{ n: 1 }, { n: 3 }]
|
|
590
|
+
* ```
|
|
591
|
+
*/
|
|
269
592
|
declare function sortBy<T>(mapFn: (value: T) => Date | boolean | number | string): (arr: T[]) => T[];
|
|
270
593
|
declare function sortBy<T>(arr: T[], mapFn: (value: T) => Date | boolean | number | string): T[];
|
|
271
594
|
//#endregion
|
|
272
595
|
//#region src/array/take.d.ts
|
|
273
596
|
/**
|
|
597
|
+
* Returns the first `limit` elements from an array.
|
|
274
598
|
*
|
|
275
|
-
* @
|
|
599
|
+
* @example
|
|
600
|
+
* ```ts
|
|
601
|
+
* take([1, 2, 3, 4], 2); // [1, 2]
|
|
602
|
+
* take(3)([1, 2, 3, 4]); // [1, 2, 3]
|
|
603
|
+
* ```
|
|
276
604
|
*/
|
|
277
605
|
declare function take<T>(limit: number): (arr: readonly T[]) => T[];
|
|
278
606
|
declare function take<T>(arr: readonly T[], limit: number): T[];
|
|
279
607
|
//#endregion
|
|
280
608
|
//#region src/array/transpose.d.ts
|
|
609
|
+
/**
|
|
610
|
+
* Transposes a matrix so rows become columns and columns become rows.
|
|
611
|
+
*
|
|
612
|
+
* @example
|
|
613
|
+
* ```ts
|
|
614
|
+
* transpose([[1, 2], [3, 4], [5, 6]]); // [[1, 3, 5], [2, 4, 6]]
|
|
615
|
+
* ```
|
|
616
|
+
*/
|
|
281
617
|
declare function transpose<T>(arr: T[][]): T[][];
|
|
282
618
|
//#endregion
|
|
283
619
|
//#region src/array/unique.d.ts
|
|
620
|
+
/**
|
|
621
|
+
* Returns a copy of an array with duplicate values removed.
|
|
622
|
+
*
|
|
623
|
+
* @example
|
|
624
|
+
* ```ts
|
|
625
|
+
* unique([1, 2, 2, 3]); // [1, 2, 3]
|
|
626
|
+
* unique([]); // []
|
|
627
|
+
* ```
|
|
628
|
+
*/
|
|
284
629
|
declare function unique<T>(arr: readonly T[]): T[];
|
|
285
630
|
//#endregion
|
|
286
631
|
//#region src/array/uniqueBy.d.ts
|
|
632
|
+
/**
|
|
633
|
+
* Returns a copy of an array with duplicates removed by a derived key.
|
|
634
|
+
* Keeps the first occurrence for each key.
|
|
635
|
+
*
|
|
636
|
+
* @example
|
|
637
|
+
* ```ts
|
|
638
|
+
* uniqueBy([{ id: 1 }, { id: 2 }, { id: 1 }], x => x.id); // [{ id: 1 }, { id: 2 }]
|
|
639
|
+
* uniqueBy(x => x.id)([{ id: 1 }, { id: 2 }, { id: 1 }]); // [{ id: 1 }, { id: 2 }]
|
|
640
|
+
* ```
|
|
641
|
+
*/
|
|
287
642
|
declare function uniqueBy<T>(mapFn: (value: T) => unknown): (arr: T[]) => T[];
|
|
288
643
|
declare function uniqueBy<T>(arr: T[], mapFn: (value: T) => unknown): T[];
|
|
289
644
|
//#endregion
|
|
290
645
|
//#region src/array/uniqueWith.d.ts
|
|
646
|
+
/**
|
|
647
|
+
* Returns a copy of an array with duplicates removed using a custom equality function.
|
|
648
|
+
* Keeps the first occurrence of each equivalent value.
|
|
649
|
+
*
|
|
650
|
+
* @example
|
|
651
|
+
* ```ts
|
|
652
|
+
* uniqueWith([1, 1.0, 2], (a, b) => a === b); // [1, 2]
|
|
653
|
+
* uniqueWith([], (a, b) => a === b); // []
|
|
654
|
+
* ```
|
|
655
|
+
*/
|
|
291
656
|
declare function uniqueWith<T>(arr: readonly T[], isEqual: (left: T, right: T) => boolean): T[];
|
|
292
657
|
//#endregion
|
|
293
658
|
//#region src/array/unshift.d.ts
|
|
294
659
|
/**
|
|
295
|
-
*
|
|
660
|
+
* Prepends a value to an array without mutating the original.
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
* ```ts
|
|
664
|
+
* unshift([1, 2], 0); // [0, 1, 2]
|
|
665
|
+
* unshift(0)([1, 2]); // [0, 1, 2]
|
|
666
|
+
* ```
|
|
296
667
|
*/
|
|
297
668
|
declare function unshift<T>(value: T): (arr: readonly T[]) => T[];
|
|
298
669
|
declare function unshift<T>(arr: readonly T[], value: T): T[];
|
|
299
670
|
//#endregion
|
|
300
671
|
//#region src/array/update.d.ts
|
|
301
672
|
/**
|
|
673
|
+
* Replaces the element at the given index using a callback without mutating the original array.
|
|
674
|
+
* Returns a range error when the index is out of bounds.
|
|
302
675
|
*
|
|
676
|
+
* @example
|
|
677
|
+
* ```ts
|
|
678
|
+
* update([1, 2, 3], 1, n => n * 10); // [1, 20, 3]
|
|
679
|
+
* update(1, n => n * 10)([1, 2, 3]); // [1, 20, 3]
|
|
680
|
+
* ```
|
|
303
681
|
*/
|
|
304
682
|
declare function update<T>(index: number, fn: (value: T) => T): (arr: readonly T[]) => RangeError | T[];
|
|
305
683
|
declare function update<T>(arr: readonly T[], index: number, fn: (value: T) => T): RangeError | T[];
|
|
@@ -311,8 +689,14 @@ declare function updateAssert<T>(arr: readonly T[], index: number, fn: (value: T
|
|
|
311
689
|
//#endregion
|
|
312
690
|
//#region src/array/window.d.ts
|
|
313
691
|
/**
|
|
692
|
+
* Creates a sliding window of consecutive elements with the given size.
|
|
693
|
+
* Returns an empty array when the window size is larger than the input.
|
|
314
694
|
*
|
|
315
|
-
* @
|
|
695
|
+
* @example
|
|
696
|
+
* ```ts
|
|
697
|
+
* window([1, 2, 3, 4], 2); // [[1, 2], [2, 3], [3, 4]]
|
|
698
|
+
* window(3)([1, 2, 3, 4]); // [[1, 2, 3], [2, 3, 4]]
|
|
699
|
+
* ```
|
|
316
700
|
*/
|
|
317
701
|
declare function window(size: number): <T>(arr: readonly T[]) => T[][];
|
|
318
702
|
declare function window<T>(arr: readonly T[], size: number): T[][];
|
|
@@ -323,12 +707,30 @@ declare function windowAssert<T>(size: number): (arr: readonly T[]) => T[][];
|
|
|
323
707
|
declare function windowAssert<T>(arr: readonly T[], size: number): T[][];
|
|
324
708
|
//#endregion
|
|
325
709
|
//#region src/array/zip.d.ts
|
|
710
|
+
/**
|
|
711
|
+
* Pairs elements from two arrays up to the length of the shorter one.
|
|
712
|
+
*
|
|
713
|
+
* @example
|
|
714
|
+
* ```ts
|
|
715
|
+
* zip([1, 2, 3], ['a', 'b']); // [[1, 'a'], [2, 'b']]
|
|
716
|
+
* zip(['a', 'b'])([1, 2, 3]); // [[1, 'a'], [2, 'b']]
|
|
717
|
+
* ```
|
|
718
|
+
*/
|
|
326
719
|
declare function zip<L, R>(other: readonly R[]): (arr: readonly L[]) => [L, R][];
|
|
327
720
|
declare function zip<L, R>(arr: readonly L[], other: readonly R[]): [L, R][];
|
|
328
721
|
//#endregion
|
|
329
722
|
//#region src/array/zipWith.d.ts
|
|
723
|
+
/**
|
|
724
|
+
* Combines two arrays element-wise using a callback, up to the length of the shorter one.
|
|
725
|
+
*
|
|
726
|
+
* @example
|
|
727
|
+
* ```ts
|
|
728
|
+
* zipWith([1, 2, 3], [10, 20], (a, b) => a + b); // [11, 22]
|
|
729
|
+
* zipWith([10, 20], (a, b) => a + b)([1, 2, 3]); // [11, 22]
|
|
730
|
+
* ```
|
|
731
|
+
*/
|
|
330
732
|
declare function zipWith<L, R, U>(other: readonly R[], fn: (l: L, R: R) => U): (arr: readonly L[]) => U[];
|
|
331
733
|
declare function zipWith<L, R, U>(arr: readonly L[], other: readonly R[], fn: (l: L, R: R) => U): U[];
|
|
332
734
|
//#endregion
|
|
333
|
-
export {
|
|
735
|
+
export { Ctor, at, chunk, concat, drop, every, find, findIndex, findLast, findLastIndex, first, flatMap, forEach, from, fromAsync, init, insert, isArray, isEmpty, isNotEmpty, join, last, length, map, of, ofLength, partition, pop, prepend, push, reduce, reduce1, reduceRight, reduceRight1, rest, reverse, scan, shift, shuffle, some, sort, sortBy, take, transpose, unique, uniqueBy, uniqueWith, unshift, update, window, zip, zipWith };
|
|
334
736
|
//# sourceMappingURL=index.d.mts.map
|