es-toolkit 1.10.1-dev.219 → 1.10.1-dev.221
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/flatMap.d.mts +23 -0
- package/dist/array/flatMap.d.ts +23 -0
- package/dist/array/flatMap.js +52 -0
- package/dist/array/flatMap.js.map +1 -0
- package/dist/array/flatMap.mjs +9 -0
- package/dist/array/index.d.mts +1 -0
- package/dist/array/index.d.ts +1 -0
- package/dist/array/index.js +7 -0
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +17 -13
- package/dist/chunk-DDH7K4QM.mjs +1 -0
- package/dist/chunk-DDH7K4QM.mjs.map +1 -0
- package/dist/chunk-KBXHURLW.mjs +13 -0
- package/dist/chunk-KBXHURLW.mjs.map +1 -0
- package/dist/compat/index.d.mts +1 -0
- package/dist/compat/index.d.ts +1 -0
- package/dist/compat/index.js +7 -0
- package/dist/compat/index.js.map +1 -1
- package/dist/compat/index.mjs +43 -39
- package/dist/compat/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -39
- package/dist/math/index.mjs +3 -3
- package/dist/string/index.mjs +6 -6
- package/package.json +1 -1
- package/dist/chunk-2MRZANXZ.mjs +0 -1
- /package/dist/{chunk-2MRZANXZ.mjs.map → array/flatMap.mjs.map} +0 -0
package/dist/array/index.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-DDH7K4QM.mjs";
|
|
2
|
+
import {
|
|
3
|
+
xor
|
|
4
|
+
} from "../chunk-L7FQX5MN.mjs";
|
|
2
5
|
import {
|
|
3
6
|
xorBy
|
|
4
7
|
} from "../chunk-Q47NGNXT.mjs";
|
|
@@ -14,6 +17,9 @@ import {
|
|
|
14
17
|
import {
|
|
15
18
|
zipWith
|
|
16
19
|
} from "../chunk-4KYXHZ4R.mjs";
|
|
20
|
+
import {
|
|
21
|
+
unionBy
|
|
22
|
+
} from "../chunk-NFS7RWWE.mjs";
|
|
17
23
|
import {
|
|
18
24
|
unionWith
|
|
19
25
|
} from "../chunk-2ZCITDMK.mjs";
|
|
@@ -33,8 +39,8 @@ import {
|
|
|
33
39
|
without
|
|
34
40
|
} from "../chunk-PYEYV7BY.mjs";
|
|
35
41
|
import {
|
|
36
|
-
|
|
37
|
-
} from "../chunk-
|
|
42
|
+
shuffle
|
|
43
|
+
} from "../chunk-G7UQ5PUR.mjs";
|
|
38
44
|
import {
|
|
39
45
|
tail
|
|
40
46
|
} from "../chunk-OF6NM4G7.mjs";
|
|
@@ -60,8 +66,8 @@ import {
|
|
|
60
66
|
uniq
|
|
61
67
|
} from "../chunk-DVK2N4KC.mjs";
|
|
62
68
|
import {
|
|
63
|
-
|
|
64
|
-
} from "../chunk-
|
|
69
|
+
keyBy
|
|
70
|
+
} from "../chunk-AJKZMN2V.mjs";
|
|
65
71
|
import {
|
|
66
72
|
last
|
|
67
73
|
} from "../chunk-KPBQ7OUY.mjs";
|
|
@@ -86,8 +92,8 @@ import {
|
|
|
86
92
|
import "../chunk-GIWAOOFY.mjs";
|
|
87
93
|
import "../chunk-SYWMYQYJ.mjs";
|
|
88
94
|
import {
|
|
89
|
-
|
|
90
|
-
} from "../chunk-
|
|
95
|
+
forEachRight
|
|
96
|
+
} from "../chunk-IEA53J7P.mjs";
|
|
91
97
|
import {
|
|
92
98
|
groupBy
|
|
93
99
|
} from "../chunk-E6E4RZLN.mjs";
|
|
@@ -106,9 +112,6 @@ import {
|
|
|
106
112
|
import {
|
|
107
113
|
intersectionWith
|
|
108
114
|
} from "../chunk-XI7KRD2C.mjs";
|
|
109
|
-
import {
|
|
110
|
-
keyBy
|
|
111
|
-
} from "../chunk-AJKZMN2V.mjs";
|
|
112
115
|
import {
|
|
113
116
|
drop
|
|
114
117
|
} from "../chunk-S3CORED5.mjs";
|
|
@@ -124,15 +127,15 @@ import {
|
|
|
124
127
|
import {
|
|
125
128
|
fill
|
|
126
129
|
} from "../chunk-6KP7CLVJ.mjs";
|
|
130
|
+
import {
|
|
131
|
+
flatMap
|
|
132
|
+
} from "../chunk-KBXHURLW.mjs";
|
|
127
133
|
import {
|
|
128
134
|
flattenDeep
|
|
129
135
|
} from "../chunk-ML727RRJ.mjs";
|
|
130
136
|
import {
|
|
131
137
|
flatten
|
|
132
138
|
} from "../chunk-33MSBDC6.mjs";
|
|
133
|
-
import {
|
|
134
|
-
forEachRight
|
|
135
|
-
} from "../chunk-IEA53J7P.mjs";
|
|
136
139
|
import {
|
|
137
140
|
chunk
|
|
138
141
|
} from "../chunk-E6C5EZQA.mjs";
|
|
@@ -164,6 +167,7 @@ export {
|
|
|
164
167
|
dropRightWhile,
|
|
165
168
|
dropWhile,
|
|
166
169
|
fill,
|
|
170
|
+
flatMap,
|
|
167
171
|
flatten,
|
|
168
172
|
flattenDeep,
|
|
169
173
|
forEachRight,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-DDH7K4QM.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
flatten
|
|
3
|
+
} from "./chunk-33MSBDC6.mjs";
|
|
4
|
+
|
|
5
|
+
// src/array/flatMap.ts
|
|
6
|
+
function flatMap(arr, iteratee, depth = 1) {
|
|
7
|
+
return flatten(arr.map((item) => iteratee(item)), depth);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
flatMap
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=chunk-KBXHURLW.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/array/flatMap.ts"],"sourcesContent":["import { flatten } from './flatten';\n\n/**\n * Maps each element in the array using the iteratee function and flattens the result up to the specified depth.\n *\n * @template T - The type of elements within the array.\n * @template U - The type of elements within the returned array from the iteratee function.\n * @template D - The depth to which the array should be flattened.\n * @param {T[]} arr - The array to flatten.\n * @param {(item: T) => U} iteratee - The function that produces the new array elements.\n * @param {D} depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.\n * @returns {Array<FlatArray<U[], D>>} The new array with the mapped and flattened elements.\n *\n * @example\n * const arr = [1, 2, 3];\n *\n * flatMap(arr, (item: number) => [item, item]);\n * // [1, 1, 2, 2, 3, 3]\n *\n * flatMap(arr, (item: number) => [[item, item]], 2);\n * // [1, 1, 2, 2, 3, 3]\n */\nexport function flatMap<T, U, D extends number>(\n arr: readonly T[],\n iteratee: (item: T) => U,\n depth = 1 as D\n): Array<FlatArray<U[], D>> {\n return flatten(arr.map(item => iteratee(item)), depth);\n}\n"],"mappings":";;;;;AAsBO,SAAS,QACd,KACA,UACA,QAAQ,GACkB;AAC1B,SAAO,QAAQ,IAAI,IAAI,UAAQ,SAAS,IAAI,CAAC,GAAG,KAAK;AACvD;","names":[]}
|
package/dist/compat/index.d.mts
CHANGED
|
@@ -8,6 +8,7 @@ export { dropRight } from '../array/dropRight.mjs';
|
|
|
8
8
|
export { dropRightWhile } from '../array/dropRightWhile.mjs';
|
|
9
9
|
export { dropWhile } from '../array/dropWhile.mjs';
|
|
10
10
|
export { fill } from '../array/fill.mjs';
|
|
11
|
+
export { flatMap } from '../array/flatMap.mjs';
|
|
11
12
|
export { flatten } from '../array/flatten.mjs';
|
|
12
13
|
export { flattenDeep } from '../array/flattenDeep.mjs';
|
|
13
14
|
export { forEachRight } from '../array/forEachRight.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { dropRight } from '../array/dropRight.js';
|
|
|
8
8
|
export { dropRightWhile } from '../array/dropRightWhile.js';
|
|
9
9
|
export { dropWhile } from '../array/dropWhile.js';
|
|
10
10
|
export { fill } from '../array/fill.js';
|
|
11
|
+
export { flatMap } from '../array/flatMap.js';
|
|
11
12
|
export { flatten } from '../array/flatten.js';
|
|
12
13
|
export { flattenDeep } from '../array/flattenDeep.js';
|
|
13
14
|
export { forEachRight } from '../array/forEachRight.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -52,6 +52,7 @@ __export(compat_exports, {
|
|
|
52
52
|
dropRightWhile: () => dropRightWhile,
|
|
53
53
|
dropWhile: () => dropWhile,
|
|
54
54
|
fill: () => fill,
|
|
55
|
+
flatMap: () => flatMap,
|
|
55
56
|
flatten: () => flatten,
|
|
56
57
|
flattenDeep: () => flattenDeep,
|
|
57
58
|
forEachRight: () => forEachRight,
|
|
@@ -233,6 +234,11 @@ function flatten(arr, depth = 1) {
|
|
|
233
234
|
return result;
|
|
234
235
|
}
|
|
235
236
|
|
|
237
|
+
// src/array/flatMap.ts
|
|
238
|
+
function flatMap(arr, iteratee, depth = 1) {
|
|
239
|
+
return flatten(arr.map((item) => iteratee(item)), depth);
|
|
240
|
+
}
|
|
241
|
+
|
|
236
242
|
// src/array/flattenDeep.ts
|
|
237
243
|
function flattenDeep(arr) {
|
|
238
244
|
return flatten(arr, Infinity);
|
|
@@ -1008,6 +1014,7 @@ function chunk2(arr, size = 1) {
|
|
|
1008
1014
|
dropRightWhile,
|
|
1009
1015
|
dropWhile,
|
|
1010
1016
|
fill,
|
|
1017
|
+
flatMap,
|
|
1011
1018
|
flatten,
|
|
1012
1019
|
flattenDeep,
|
|
1013
1020
|
forEachRight,
|