es-toolkit 1.13.1-dev.321 → 1.13.1-dev.322
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/compact.d.mts +1 -1
- package/dist/array/compact.d.ts +1 -1
- package/dist/array/compact.js.map +1 -1
- package/dist/array/compact.mjs +1 -1
- package/dist/array/fill.d.mts +1 -0
- package/dist/array/fill.d.ts +1 -0
- package/dist/array/fill.js.map +1 -1
- package/dist/array/fill.mjs +1 -1
- package/dist/array/head.d.mts +1 -0
- package/dist/array/head.d.ts +1 -0
- package/dist/array/head.js.map +1 -1
- package/dist/array/head.mjs +1 -1
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +23 -23
- package/dist/array/last.d.mts +1 -0
- package/dist/array/last.d.ts +1 -0
- package/dist/array/last.js.map +1 -1
- package/dist/array/last.mjs +1 -1
- package/dist/array/tail.d.mts +9 -4
- package/dist/array/tail.d.ts +9 -4
- package/dist/array/tail.js.map +1 -1
- package/dist/array/tail.mjs +1 -1
- package/dist/array/toFilled.d.mts +2 -0
- package/dist/array/toFilled.d.ts +2 -0
- package/dist/array/toFilled.js.map +1 -1
- package/dist/array/toFilled.mjs +1 -1
- package/dist/array/unzip.d.mts +3 -2
- package/dist/array/unzip.d.ts +3 -2
- package/dist/array/unzip.js.map +1 -1
- package/dist/array/unzip.mjs +1 -1
- package/dist/array/zipWith.d.mts +5 -0
- package/dist/array/zipWith.d.ts +5 -0
- package/dist/array/zipWith.js.map +1 -1
- package/dist/array/zipWith.mjs +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +23 -23
- package/dist/{chunk-TJ4Z5I7M.mjs → chunk-DLS7UJKJ.mjs} +1 -1
- package/dist/chunk-DLS7UJKJ.mjs.map +1 -0
- package/dist/{chunk-KPBQ7OUY.mjs → chunk-DTTKJ3VC.mjs} +1 -1
- package/dist/chunk-DTTKJ3VC.mjs.map +1 -0
- package/dist/{chunk-IGM5IABU.mjs → chunk-EEHJ656S.mjs} +45 -45
- package/dist/chunk-EEHJ656S.mjs.map +1 -0
- package/dist/{chunk-HM2JT2RX.mjs → chunk-FZZNWXDM.mjs} +1 -1
- package/dist/chunk-FZZNWXDM.mjs.map +1 -0
- package/dist/{chunk-YFN6KOC4.mjs → chunk-GTFDDKZ2.mjs} +1 -1
- package/dist/chunk-GTFDDKZ2.mjs.map +1 -0
- package/dist/{chunk-UYZKMBDO.mjs → chunk-JCRY7ZYS.mjs} +1 -1
- package/dist/chunk-JCRY7ZYS.mjs.map +1 -0
- package/dist/{chunk-4KYXHZ4R.mjs → chunk-MJ7LNBI6.mjs} +1 -1
- package/dist/chunk-MJ7LNBI6.mjs.map +1 -0
- package/dist/{chunk-DTJJIMKJ.mjs → chunk-PJPGJ2O6.mjs} +1 -1
- package/dist/chunk-PJPGJ2O6.mjs.map +1 -0
- package/dist/{chunk-OP4OAKQJ.mjs → chunk-XHSIT5DL.mjs} +1 -1
- package/dist/chunk-XHSIT5DL.mjs.map +1 -0
- package/dist/compat/index.d.mts +2 -1
- package/dist/compat/index.d.ts +2 -1
- package/dist/compat/index.js.map +1 -1
- package/dist/compat/index.mjs +44 -44
- package/dist/function/index.mjs +9 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -45
- package/package.json +1 -1
- package/dist/chunk-4KYXHZ4R.mjs.map +0 -1
- package/dist/chunk-DTJJIMKJ.mjs.map +0 -1
- package/dist/chunk-HM2JT2RX.mjs.map +0 -1
- package/dist/chunk-IGM5IABU.mjs.map +0 -1
- package/dist/chunk-KPBQ7OUY.mjs.map +0 -1
- package/dist/chunk-OP4OAKQJ.mjs.map +0 -1
- package/dist/chunk-TJ4Z5I7M.mjs.map +0 -1
- package/dist/chunk-UYZKMBDO.mjs.map +0 -1
- package/dist/chunk-YFN6KOC4.mjs.map +0 -1
package/dist/array/index.mjs
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import "../chunk-DDH7K4QM.mjs";
|
|
2
|
-
import {
|
|
3
|
-
zipObject
|
|
4
|
-
} from "../chunk-6GWEY5EL.mjs";
|
|
5
2
|
import {
|
|
6
3
|
zipWith
|
|
7
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-MJ7LNBI6.mjs";
|
|
8
5
|
import {
|
|
9
6
|
unzip
|
|
10
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-JCRY7ZYS.mjs";
|
|
11
8
|
import {
|
|
12
9
|
unzipWith
|
|
13
10
|
} from "../chunk-IFNXROZR.mjs";
|
|
@@ -27,14 +24,14 @@ import {
|
|
|
27
24
|
zip
|
|
28
25
|
} from "../chunk-OLORW442.mjs";
|
|
29
26
|
import {
|
|
30
|
-
|
|
31
|
-
} from "../chunk-
|
|
27
|
+
zipObject
|
|
28
|
+
} from "../chunk-6GWEY5EL.mjs";
|
|
32
29
|
import {
|
|
33
30
|
takeWhile
|
|
34
31
|
} from "../chunk-2IXFGSUA.mjs";
|
|
35
32
|
import {
|
|
36
33
|
toFilled
|
|
37
|
-
} from "../chunk-
|
|
34
|
+
} from "../chunk-XHSIT5DL.mjs";
|
|
38
35
|
import {
|
|
39
36
|
union
|
|
40
37
|
} from "../chunk-R6QA7PLZ.mjs";
|
|
@@ -44,9 +41,6 @@ import {
|
|
|
44
41
|
import {
|
|
45
42
|
unionWith
|
|
46
43
|
} from "../chunk-2ZCITDMK.mjs";
|
|
47
|
-
import {
|
|
48
|
-
uniqWith
|
|
49
|
-
} from "../chunk-237HGSZS.mjs";
|
|
50
44
|
import {
|
|
51
45
|
uniq
|
|
52
46
|
} from "../chunk-DVK2N4KC.mjs";
|
|
@@ -54,8 +48,8 @@ import {
|
|
|
54
48
|
uniqBy
|
|
55
49
|
} from "../chunk-B4COTK4K.mjs";
|
|
56
50
|
import {
|
|
57
|
-
|
|
58
|
-
} from "../chunk-
|
|
51
|
+
uniqWith
|
|
52
|
+
} from "../chunk-237HGSZS.mjs";
|
|
59
53
|
import {
|
|
60
54
|
partition
|
|
61
55
|
} from "../chunk-DN3NOZ3H.mjs";
|
|
@@ -72,7 +66,7 @@ import {
|
|
|
72
66
|
} from "../chunk-G7UQ5PUR.mjs";
|
|
73
67
|
import {
|
|
74
68
|
tail
|
|
75
|
-
} from "../chunk-
|
|
69
|
+
} from "../chunk-DLS7UJKJ.mjs";
|
|
76
70
|
import {
|
|
77
71
|
take
|
|
78
72
|
} from "../chunk-ME352XO7.mjs";
|
|
@@ -80,8 +74,8 @@ import {
|
|
|
80
74
|
takeRight
|
|
81
75
|
} from "../chunk-N3QYJX4T.mjs";
|
|
82
76
|
import {
|
|
83
|
-
|
|
84
|
-
} from "../chunk-
|
|
77
|
+
takeRightWhile
|
|
78
|
+
} from "../chunk-NTLX2MPV.mjs";
|
|
85
79
|
import {
|
|
86
80
|
intersection
|
|
87
81
|
} from "../chunk-FVVSE2F2.mjs";
|
|
@@ -96,7 +90,7 @@ import {
|
|
|
96
90
|
} from "../chunk-AJKZMN2V.mjs";
|
|
97
91
|
import {
|
|
98
92
|
last
|
|
99
|
-
} from "../chunk-
|
|
93
|
+
} from "../chunk-DTTKJ3VC.mjs";
|
|
100
94
|
import {
|
|
101
95
|
maxBy
|
|
102
96
|
} from "../chunk-OOKNBU4V.mjs";
|
|
@@ -104,8 +98,8 @@ import {
|
|
|
104
98
|
minBy
|
|
105
99
|
} from "../chunk-IJD7FE2Z.mjs";
|
|
106
100
|
import {
|
|
107
|
-
|
|
108
|
-
} from "../chunk-
|
|
101
|
+
orderBy
|
|
102
|
+
} from "../chunk-7B7W36UP.mjs";
|
|
109
103
|
import {
|
|
110
104
|
flatMap
|
|
111
105
|
} from "../chunk-UY76KTPE.mjs";
|
|
@@ -123,10 +117,10 @@ import {
|
|
|
123
117
|
} from "../chunk-E6E4RZLN.mjs";
|
|
124
118
|
import {
|
|
125
119
|
head
|
|
126
|
-
} from "../chunk-
|
|
120
|
+
} from "../chunk-FZZNWXDM.mjs";
|
|
127
121
|
import {
|
|
128
|
-
|
|
129
|
-
} from "../chunk-
|
|
122
|
+
initial
|
|
123
|
+
} from "../chunk-XPSOKBRZ.mjs";
|
|
130
124
|
import {
|
|
131
125
|
difference
|
|
132
126
|
} from "../chunk-JPUKH67K.mjs";
|
|
@@ -148,12 +142,18 @@ import {
|
|
|
148
142
|
import {
|
|
149
143
|
dropWhile
|
|
150
144
|
} from "../chunk-LJ2C6MVP.mjs";
|
|
145
|
+
import {
|
|
146
|
+
fill
|
|
147
|
+
} from "../chunk-GTFDDKZ2.mjs";
|
|
151
148
|
import {
|
|
152
149
|
chunk
|
|
153
150
|
} from "../chunk-E6C5EZQA.mjs";
|
|
154
151
|
import {
|
|
155
152
|
compact
|
|
156
|
-
} from "../chunk-
|
|
153
|
+
} from "../chunk-PJPGJ2O6.mjs";
|
|
154
|
+
import {
|
|
155
|
+
countBy
|
|
156
|
+
} from "../chunk-Z7HWEOQX.mjs";
|
|
157
157
|
import "../chunk-J5LGTIGS.mjs";
|
|
158
158
|
export {
|
|
159
159
|
chunk,
|
package/dist/array/last.d.mts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* Unlike some implementations, this function is optimized for performance
|
|
8
8
|
* by directly accessing the last index of the array.
|
|
9
9
|
*
|
|
10
|
+
* @template T - The type of elements in the array.
|
|
10
11
|
* @param {T[]} arr - The array from which to get the last element.
|
|
11
12
|
* @returns {T | undefined} The last element of the array, or `undefined` if the array is empty.
|
|
12
13
|
*
|
package/dist/array/last.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* Unlike some implementations, this function is optimized for performance
|
|
8
8
|
* by directly accessing the last index of the array.
|
|
9
9
|
*
|
|
10
|
+
* @template T - The type of elements in the array.
|
|
10
11
|
* @param {T[]} arr - The array from which to get the last element.
|
|
11
12
|
* @returns {T | undefined} The last element of the array, or `undefined` if the array is empty.
|
|
12
13
|
*
|
package/dist/array/last.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/last.ts"],"sourcesContent":["/**\n * Returns the last element of an array.\n *\n * This function takes an array and returns the last element of the array.\n * If the array is empty, the function returns `undefined`.\n *\n * Unlike some implementations, this function is optimized for performance\n * by directly accessing the last index of the array.\n *\n * @param {T[]} arr - The array from which to get the last element.\n * @returns {T | undefined} The last element of the array, or `undefined` if the array is empty.\n *\n * @example\n * const arr = [1, 2, 3];\n * const lastElement = last(arr);\n * // lastElement will be 3\n *\n * const emptyArr: number[] = [];\n * const noElement = last(emptyArr);\n * // noElement will be undefined\n */\n\nexport function last<T>(arr: readonly [...T[], T]): T;\nexport function last<T>(arr: readonly T[]): T | undefined;\nexport function last<T>(arr: readonly T[]): T | undefined {\n return arr[arr.length - 1];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/array/last.ts"],"sourcesContent":["/**\n * Returns the last element of an array.\n *\n * This function takes an array and returns the last element of the array.\n * If the array is empty, the function returns `undefined`.\n *\n * Unlike some implementations, this function is optimized for performance\n * by directly accessing the last index of the array.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to get the last element.\n * @returns {T | undefined} The last element of the array, or `undefined` if the array is empty.\n *\n * @example\n * const arr = [1, 2, 3];\n * const lastElement = last(arr);\n * // lastElement will be 3\n *\n * const emptyArr: number[] = [];\n * const noElement = last(emptyArr);\n * // noElement will be undefined\n */\n\nexport function last<T>(arr: readonly [...T[], T]): T;\nexport function last<T>(arr: readonly T[]): T | undefined;\nexport function last<T>(arr: readonly T[]): T | undefined {\n return arr[arr.length - 1];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBO,SAAS,KAAQ,KAAkC;AACxD,SAAO,IAAI,IAAI,SAAS,CAAC;AAC3B;","names":[]}
|
package/dist/array/last.mjs
CHANGED
package/dist/array/tail.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns an empty array when the input is a single-element array.
|
|
3
3
|
*
|
|
4
|
-
* @
|
|
4
|
+
* @template T - The type of the single element in the array.
|
|
5
|
+
* @param {[T]} arr - The single-element array to process.
|
|
5
6
|
* @returns {[]} An empty array.
|
|
6
7
|
*
|
|
7
8
|
* @example
|
|
@@ -13,7 +14,8 @@ declare function tail<T>(arr: readonly [T]): [];
|
|
|
13
14
|
/**
|
|
14
15
|
* Returns an empty array when the input is an empty array.
|
|
15
16
|
*
|
|
16
|
-
* @
|
|
17
|
+
* @template T - The type of elements in the array.
|
|
18
|
+
* @param {[]} arr - The empty array to process.
|
|
17
19
|
* @returns {[]} An empty array.
|
|
18
20
|
*
|
|
19
21
|
* @example
|
|
@@ -25,7 +27,9 @@ declare function tail(arr: readonly []): [];
|
|
|
25
27
|
/**
|
|
26
28
|
* Returns a new array with all elements except for the first when the input is a tuple array.
|
|
27
29
|
*
|
|
28
|
-
* @
|
|
30
|
+
* @template T - The type of the first element in the tuple array.
|
|
31
|
+
* @template U - The type of the remaining elements in the tuple array.
|
|
32
|
+
* @param {[T, ...U[]]} arr - The tuple array to process.
|
|
29
33
|
* @returns {U[]} A new array containing all elements of the input array except for the first one.
|
|
30
34
|
*
|
|
31
35
|
* @example
|
|
@@ -41,7 +45,8 @@ declare function tail<T, U>(arr: readonly [T, ...U[]]): U[];
|
|
|
41
45
|
* except for the first one. If the input array is empty or has only one element,
|
|
42
46
|
* an empty array is returned.
|
|
43
47
|
*
|
|
44
|
-
* @
|
|
48
|
+
* @template T - The type of elements in the array.
|
|
49
|
+
* @param {T[]} arr - The array to get the tail of.
|
|
45
50
|
* @returns {T[]} A new array containing all elements of the input array except for the first one.
|
|
46
51
|
*
|
|
47
52
|
* @example
|
package/dist/array/tail.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns an empty array when the input is a single-element array.
|
|
3
3
|
*
|
|
4
|
-
* @
|
|
4
|
+
* @template T - The type of the single element in the array.
|
|
5
|
+
* @param {[T]} arr - The single-element array to process.
|
|
5
6
|
* @returns {[]} An empty array.
|
|
6
7
|
*
|
|
7
8
|
* @example
|
|
@@ -13,7 +14,8 @@ declare function tail<T>(arr: readonly [T]): [];
|
|
|
13
14
|
/**
|
|
14
15
|
* Returns an empty array when the input is an empty array.
|
|
15
16
|
*
|
|
16
|
-
* @
|
|
17
|
+
* @template T - The type of elements in the array.
|
|
18
|
+
* @param {[]} arr - The empty array to process.
|
|
17
19
|
* @returns {[]} An empty array.
|
|
18
20
|
*
|
|
19
21
|
* @example
|
|
@@ -25,7 +27,9 @@ declare function tail(arr: readonly []): [];
|
|
|
25
27
|
/**
|
|
26
28
|
* Returns a new array with all elements except for the first when the input is a tuple array.
|
|
27
29
|
*
|
|
28
|
-
* @
|
|
30
|
+
* @template T - The type of the first element in the tuple array.
|
|
31
|
+
* @template U - The type of the remaining elements in the tuple array.
|
|
32
|
+
* @param {[T, ...U[]]} arr - The tuple array to process.
|
|
29
33
|
* @returns {U[]} A new array containing all elements of the input array except for the first one.
|
|
30
34
|
*
|
|
31
35
|
* @example
|
|
@@ -41,7 +45,8 @@ declare function tail<T, U>(arr: readonly [T, ...U[]]): U[];
|
|
|
41
45
|
* except for the first one. If the input array is empty or has only one element,
|
|
42
46
|
* an empty array is returned.
|
|
43
47
|
*
|
|
44
|
-
* @
|
|
48
|
+
* @template T - The type of elements in the array.
|
|
49
|
+
* @param {T[]} arr - The array to get the tail of.
|
|
45
50
|
* @returns {T[]} A new array containing all elements of the input array except for the first one.
|
|
46
51
|
*
|
|
47
52
|
* @example
|
package/dist/array/tail.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/tail.ts"],"sourcesContent":["/**\n * Returns an empty array when the input is a single-element array.\n *\n * @param {
|
|
1
|
+
{"version":3,"sources":["../../src/array/tail.ts"],"sourcesContent":["/**\n * Returns an empty array when the input is a single-element array.\n *\n * @template T - The type of the single element in the array.\n * @param {[T]} arr - The single-element array to process.\n * @returns {[]} An empty array.\n *\n * @example\n * const arr = [1];\n * const result = tail(arr);\n * // result will be []\n */\nexport function tail<T>(arr: readonly [T]): [];\n\n/**\n * Returns an empty array when the input is an empty array.\n *\n * @template T - The type of elements in the array.\n * @param {[]} arr - The empty array to process.\n * @returns {[]} An empty array.\n *\n * @example\n * const arr = [];\n * const result = tail(arr);\n * // result will be []\n */\nexport function tail(arr: readonly []): [];\n\n/**\n * Returns a new array with all elements except for the first when the input is a tuple array.\n *\n * @template T - The type of the first element in the tuple array.\n * @template U - The type of the remaining elements in the tuple array.\n * @param {[T, ...U[]]} arr - The tuple array to process.\n * @returns {U[]} A new array containing all elements of the input array except for the first one.\n *\n * @example\n * const arr = [1, 2, 3];\n * const result = tail(arr);\n * // result will be [2, 3]\n */\nexport function tail<T, U>(arr: readonly [T, ...U[]]): U[];\n\n/**\n * Returns a new array with all elements except for the first.\n *\n * This function takes an array and returns a new array containing all the elements\n * except for the first one. If the input array is empty or has only one element,\n * an empty array is returned.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to get the tail of.\n * @returns {T[]} A new array containing all elements of the input array except for the first one.\n *\n * @example\n * const arr1 = [1, 2, 3];\n * const result = tail(arr1);\n * // result will be [2, 3]\n *\n * const arr2 = [1];\n * const result2 = tail(arr2);\n * // result2 will be []\n *\n * const arr3 = [];\n * const result3 = tail(arr3);\n * // result3 will be []\n */\nexport function tail<T>(arr: readonly T[]): T[];\n\nexport function tail<T>(arr: readonly T[]): T[] {\n const len = arr.length;\n if (len <= 1) {\n return [];\n }\n const result = new Array(len - 1);\n for (let i = 1; i < len; i++) {\n result[i - 1] = arr[i];\n }\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqEO,SAAS,KAAQ,KAAwB;AAC9C,QAAM,MAAM,IAAI;AAChB,MAAI,OAAO,GAAG;AACZ,WAAO,CAAC;AAAA,EACV;AACA,QAAM,SAAS,IAAI,MAAM,MAAM,CAAC;AAChC,WAAS,IAAI,GAAG,IAAI,KAAK,KAAK;AAC5B,WAAO,IAAI,CAAC,IAAI,IAAI,CAAC;AAAA,EACvB;AACA,SAAO;AACT;","names":[]}
|
package/dist/array/tail.mjs
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Creates a new array filled with the specified value from the start position up to, but not including, the end position.
|
|
3
3
|
* This function does not mutate the original array.
|
|
4
4
|
*
|
|
5
|
+
* @template T - The type of elements in the original array.
|
|
6
|
+
* @template U - The type of the value to fill the new array with.
|
|
5
7
|
* @param {Array<T>} arr - The array to base the new array on.
|
|
6
8
|
* @param {U} value - The value to fill the new array with.
|
|
7
9
|
* @param {number} [start=0] - The start position. Defaults to 0.
|
package/dist/array/toFilled.d.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Creates a new array filled with the specified value from the start position up to, but not including, the end position.
|
|
3
3
|
* This function does not mutate the original array.
|
|
4
4
|
*
|
|
5
|
+
* @template T - The type of elements in the original array.
|
|
6
|
+
* @template U - The type of the value to fill the new array with.
|
|
5
7
|
* @param {Array<T>} arr - The array to base the new array on.
|
|
6
8
|
* @param {U} value - The value to fill the new array with.
|
|
7
9
|
* @param {number} [start=0] - The start position. Defaults to 0.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/toFilled.ts"],"sourcesContent":["/**\n * Creates a new array filled with the specified value from the start position up to, but not including, the end position.\n * This function does not mutate the original array.\n *\n * @param {Array<T>} arr - The array to base the new array on.\n * @param {U} value - The value to fill the new array with.\n * @param {number} [start=0] - The start position. Defaults to 0.\n * @param {number} [end=arr.length] - The end position. Defaults to the array's length.\n * @returns {Array<T | U>} The new array with the filled values.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * let result = toFilled(array, '*', 2);\n * console.log(result); // [1, 2, '*', '*', '*']\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*', 1, 4);\n * console.log(result); // [1, '*', '*', '*', 5]\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*');\n * console.log(result); // ['*', '*', '*', '*', '*']\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*', -4, -1);\n * console.log(result); // [1, '*', '*', '*', 5]\n * console.log(array); // [1, 2, 3, 4, 5]\n */\n\nexport function toFilled<T, U>(arr: T[], value: U): Array<T | U>;\nexport function toFilled<T, U>(arr: T[], value: U, start: number): Array<T | U>;\nexport function toFilled<T, U>(arr: T[], value: U, start: number, end: number): Array<T | U>;\nexport function toFilled<T, U>(arr: T[], value: U, start = 0, end = arr.length): Array<T | U> {\n const length = arr.length;\n const finalStart = Math.max(start >= 0 ? start : length + start, 0);\n const finalEnd = Math.min(end >= 0 ? end : length + end, length);\n\n const newArr: Array<T | U> = arr.slice();\n\n for (let i = finalStart; i < finalEnd; i++) {\n newArr[i] = value;\n }\n\n return newArr;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/array/toFilled.ts"],"sourcesContent":["/**\n * Creates a new array filled with the specified value from the start position up to, but not including, the end position.\n * This function does not mutate the original array.\n *\n * @template T - The type of elements in the original array.\n * @template U - The type of the value to fill the new array with.\n * @param {Array<T>} arr - The array to base the new array on.\n * @param {U} value - The value to fill the new array with.\n * @param {number} [start=0] - The start position. Defaults to 0.\n * @param {number} [end=arr.length] - The end position. Defaults to the array's length.\n * @returns {Array<T | U>} The new array with the filled values.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * let result = toFilled(array, '*', 2);\n * console.log(result); // [1, 2, '*', '*', '*']\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*', 1, 4);\n * console.log(result); // [1, '*', '*', '*', 5]\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*');\n * console.log(result); // ['*', '*', '*', '*', '*']\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*', -4, -1);\n * console.log(result); // [1, '*', '*', '*', 5]\n * console.log(array); // [1, 2, 3, 4, 5]\n */\n\nexport function toFilled<T, U>(arr: T[], value: U): Array<T | U>;\nexport function toFilled<T, U>(arr: T[], value: U, start: number): Array<T | U>;\nexport function toFilled<T, U>(arr: T[], value: U, start: number, end: number): Array<T | U>;\nexport function toFilled<T, U>(arr: T[], value: U, start = 0, end = arr.length): Array<T | U> {\n const length = arr.length;\n const finalStart = Math.max(start >= 0 ? start : length + start, 0);\n const finalEnd = Math.min(end >= 0 ? end : length + end, length);\n\n const newArr: Array<T | U> = arr.slice();\n\n for (let i = finalStart; i < finalEnd; i++) {\n newArr[i] = value;\n }\n\n return newArr;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkCO,SAAS,SAAe,KAAU,OAAU,QAAQ,GAAG,MAAM,IAAI,QAAsB;AAC5F,QAAM,SAAS,IAAI;AACnB,QAAM,aAAa,KAAK,IAAI,SAAS,IAAI,QAAQ,SAAS,OAAO,CAAC;AAClE,QAAM,WAAW,KAAK,IAAI,OAAO,IAAI,MAAM,SAAS,KAAK,MAAM;AAE/D,QAAM,SAAuB,IAAI,MAAM;AAEvC,WAAS,IAAI,YAAY,IAAI,UAAU,KAAK;AAC1C,WAAO,CAAC,IAAI;AAAA,EACd;AAEA,SAAO;AACT;","names":[]}
|
package/dist/array/toFilled.mjs
CHANGED
package/dist/array/unzip.d.mts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Gathers elements in the same position in an internal array
|
|
3
3
|
* from a grouped array of elements and returns them as a new array.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
6
|
-
* @
|
|
5
|
+
* @template T - The type of elements in the nested array.
|
|
6
|
+
* @param {Array<[...T]>} zipped - The nested array to unzip.
|
|
7
|
+
* @returns {Unzip<T>} A new array of unzipped elements.
|
|
7
8
|
*
|
|
8
9
|
* @example
|
|
9
10
|
* const zipped = [['a', true, 1],['b', false, 2]];
|
package/dist/array/unzip.d.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Gathers elements in the same position in an internal array
|
|
3
3
|
* from a grouped array of elements and returns them as a new array.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
6
|
-
* @
|
|
5
|
+
* @template T - The type of elements in the nested array.
|
|
6
|
+
* @param {Array<[...T]>} zipped - The nested array to unzip.
|
|
7
|
+
* @returns {Unzip<T>} A new array of unzipped elements.
|
|
7
8
|
*
|
|
8
9
|
* @example
|
|
9
10
|
* const zipped = [['a', true, 1],['b', false, 2]];
|
package/dist/array/unzip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/unzip.ts"],"sourcesContent":["/**\n * Gathers elements in the same position in an internal array
|
|
1
|
+
{"version":3,"sources":["../../src/array/unzip.ts"],"sourcesContent":["/**\n * Gathers elements in the same position in an internal array\n * from a grouped array of elements and returns them as a new array.\n *\n * @template T - The type of elements in the nested array.\n * @param {Array<[...T]>} zipped - The nested array to unzip.\n * @returns {Unzip<T>} A new array of unzipped elements.\n *\n * @example\n * const zipped = [['a', true, 1],['b', false, 2]];\n * const result = unzip(zipped);\n * // result will be [['a', 'b'], [true, false], [1, 2]]\n */\nexport function unzip<T extends unknown[]>(zipped: Array<[...T]>): Unzip<T> {\n // For performance reasons, use this implementation instead of\n // const maxLen = Math.max(...zipped.map(arr => arr.length));\n let maxLen = 0;\n\n for (let i = 0; i < zipped.length; i++) {\n if (zipped[i].length > maxLen) {\n maxLen = zipped[i].length;\n }\n }\n\n const result = new Array(maxLen) as Unzip<T>;\n\n for (let i = 0; i < maxLen; i++) {\n result[i] = new Array(zipped.length);\n for (let j = 0; j < zipped.length; j++) {\n result[i][j] = zipped[j][i];\n }\n }\n\n return result;\n}\n\ntype Unzip<K extends unknown[]> = { [I in keyof K]: Array<K[I]> };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,MAA2B,QAAiC;AAG1E,MAAI,SAAS;AAEb,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,QAAI,OAAO,CAAC,EAAE,SAAS,QAAQ;AAC7B,eAAS,OAAO,CAAC,EAAE;AAAA,IACrB;AAAA,EACF;AAEA,QAAM,SAAS,IAAI,MAAM,MAAM;AAE/B,WAAS,IAAI,GAAG,IAAI,QAAQ,KAAK;AAC/B,WAAO,CAAC,IAAI,IAAI,MAAM,OAAO,MAAM;AACnC,aAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,aAAO,CAAC,EAAE,CAAC,IAAI,OAAO,CAAC,EAAE,CAAC;AAAA,IAC5B;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/array/unzip.mjs
CHANGED
package/dist/array/zipWith.d.mts
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
* This function takes multiple arrays and a combiner function, and returns a new array where each element
|
|
5
5
|
* is the result of applying the combiner function to the corresponding elements of the input arrays.
|
|
6
6
|
*
|
|
7
|
+
* @template T - The type of elements in the first array.
|
|
8
|
+
* @template U - The type of elements in the second array (optional).
|
|
9
|
+
* @template V - The type of elements in the third array (optional).
|
|
10
|
+
* @template W - The type of elements in the fourth array (optional).
|
|
11
|
+
* @template R - The type of elements in the resulting array.
|
|
7
12
|
* @param {T[]} arr1 - The first array to zip.
|
|
8
13
|
* @param {U[]} [arr2] - The second array to zip (optional).
|
|
9
14
|
* @param {V[]} [arr3] - The third array to zip (optional).
|
package/dist/array/zipWith.d.ts
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
* This function takes multiple arrays and a combiner function, and returns a new array where each element
|
|
5
5
|
* is the result of applying the combiner function to the corresponding elements of the input arrays.
|
|
6
6
|
*
|
|
7
|
+
* @template T - The type of elements in the first array.
|
|
8
|
+
* @template U - The type of elements in the second array (optional).
|
|
9
|
+
* @template V - The type of elements in the third array (optional).
|
|
10
|
+
* @template W - The type of elements in the fourth array (optional).
|
|
11
|
+
* @template R - The type of elements in the resulting array.
|
|
7
12
|
* @param {T[]} arr1 - The first array to zip.
|
|
8
13
|
* @param {U[]} [arr2] - The second array to zip (optional).
|
|
9
14
|
* @param {V[]} [arr3] - The third array to zip (optional).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/zipWith.ts"],"sourcesContent":["/**\n * Combines multiple arrays into a single array using a custom combiner function.\n *\n * This function takes multiple arrays and a combiner function, and returns a new array where each element\n * is the result of applying the combiner function to the corresponding elements of the input arrays.\n *\n * @param {T[]} arr1 - The first array to zip.\n * @param {U[]} [arr2] - The second array to zip (optional).\n * @param {V[]} [arr3] - The third array to zip (optional).\n * @param {W[]} [arr4] - The fourth array to zip (optional).\n * @param {(...items: T[]) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.\n * @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.\n *\n * @example\n * // Example usage with two arrays:\n * const arr1 = [1, 2, 3];\n * const arr2 = [4, 5, 6];\n * const result = zipWith(arr1, arr2, (a, b) => a + b);\n * // result will be [5, 7, 9]\n *\n * @example\n * // Example usage with three arrays:\n * const arr1 = [1, 2];\n * const arr2 = [3, 4];\n * const arr3 = [5, 6];\n * const result = zipWith(arr1, arr2, arr3, (a, b, c) => `${a}${b}${c}`);\n * // result will be [`135`, `246`]\n */\nexport function zipWith<T, R>(arr1: readonly T[], combine: (item: T) => R): R[];\nexport function zipWith<T, U, R>(arr1: readonly T[], arr2: readonly U[], combine: (item1: T, item2: U) => R): R[];\nexport function zipWith<T, U, V, R>(\n arr1: readonly T[],\n arr2: readonly U[],\n arr3: readonly V[],\n combine: (item1: T, item2: U, item3: V) => R\n): R[];\nexport function zipWith<T, U, V, W, R>(\n arr1: readonly T[],\n arr2: readonly U[],\n arr3: readonly V[],\n arr4: readonly W[],\n combine: (item1: T, item2: U, item3: V, item4: W) => R\n): R[];\nexport function zipWith<T, R>(arr1: readonly T[], ...rest: any[]): R[] {\n const arrs = [arr1, ...rest.slice(0, -1)];\n const combine = rest[rest.length - 1] as (...items: T[]) => R;\n\n const result: R[] = [];\n const maxIndex = Math.max(...arrs.map(arr => arr.length));\n\n for (let i = 0; i < maxIndex; i++) {\n const elements: T[] = arrs.map(arr => arr[i]);\n result.push(combine(...elements));\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/array/zipWith.ts"],"sourcesContent":["/**\n * Combines multiple arrays into a single array using a custom combiner function.\n *\n * This function takes multiple arrays and a combiner function, and returns a new array where each element\n * is the result of applying the combiner function to the corresponding elements of the input arrays.\n *\n * @template T - The type of elements in the first array.\n * @template U - The type of elements in the second array (optional).\n * @template V - The type of elements in the third array (optional).\n * @template W - The type of elements in the fourth array (optional).\n * @template R - The type of elements in the resulting array.\n * @param {T[]} arr1 - The first array to zip.\n * @param {U[]} [arr2] - The second array to zip (optional).\n * @param {V[]} [arr3] - The third array to zip (optional).\n * @param {W[]} [arr4] - The fourth array to zip (optional).\n * @param {(...items: T[]) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.\n * @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.\n *\n * @example\n * // Example usage with two arrays:\n * const arr1 = [1, 2, 3];\n * const arr2 = [4, 5, 6];\n * const result = zipWith(arr1, arr2, (a, b) => a + b);\n * // result will be [5, 7, 9]\n *\n * @example\n * // Example usage with three arrays:\n * const arr1 = [1, 2];\n * const arr2 = [3, 4];\n * const arr3 = [5, 6];\n * const result = zipWith(arr1, arr2, arr3, (a, b, c) => `${a}${b}${c}`);\n * // result will be [`135`, `246`]\n */\nexport function zipWith<T, R>(arr1: readonly T[], combine: (item: T) => R): R[];\nexport function zipWith<T, U, R>(arr1: readonly T[], arr2: readonly U[], combine: (item1: T, item2: U) => R): R[];\nexport function zipWith<T, U, V, R>(\n arr1: readonly T[],\n arr2: readonly U[],\n arr3: readonly V[],\n combine: (item1: T, item2: U, item3: V) => R\n): R[];\nexport function zipWith<T, U, V, W, R>(\n arr1: readonly T[],\n arr2: readonly U[],\n arr3: readonly V[],\n arr4: readonly W[],\n combine: (item1: T, item2: U, item3: V, item4: W) => R\n): R[];\nexport function zipWith<T, R>(arr1: readonly T[], ...rest: any[]): R[] {\n const arrs = [arr1, ...rest.slice(0, -1)];\n const combine = rest[rest.length - 1] as (...items: T[]) => R;\n\n const result: R[] = [];\n const maxIndex = Math.max(...arrs.map(arr => arr.length));\n\n for (let i = 0; i < maxIndex; i++) {\n const elements: T[] = arrs.map(arr => arr[i]);\n result.push(combine(...elements));\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgDO,SAAS,QAAc,SAAuB,MAAkB;AACrE,QAAM,OAAO,CAAC,MAAM,GAAG,KAAK,MAAM,GAAG,EAAE,CAAC;AACxC,QAAM,UAAU,KAAK,KAAK,SAAS,CAAC;AAEpC,QAAM,SAAc,CAAC;AACrB,QAAM,WAAW,KAAK,IAAI,GAAG,KAAK,IAAI,SAAO,IAAI,MAAM,CAAC;AAExD,WAAS,IAAI,GAAG,IAAI,UAAU,KAAK;AACjC,UAAM,WAAgB,KAAK,IAAI,SAAO,IAAI,CAAC,CAAC;AAC5C,WAAO,KAAK,QAAQ,GAAG,QAAQ,CAAC;AAAA,EAClC;AAEA,SAAO;AACT;","names":[]}
|