es-toolkit 1.11.0 → 1.12.0-dev.267
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/CHANGELOG.md +7 -0
- package/dist/array/index.mjs +31 -31
- package/dist/compat/index.d.mts +33 -1
- package/dist/compat/index.d.ts +33 -1
- package/dist/compat/index.js +36 -6
- package/dist/compat/index.js.map +1 -1
- package/dist/compat/index.mjs +80 -52
- package/dist/compat/index.mjs.map +1 -1
- package/dist/function/index.mjs +6 -6
- package/dist/index.mjs +52 -52
- package/package.json +21 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# es-toolkit Changelog
|
|
2
2
|
|
|
3
|
+
## Version v1.12.0
|
|
4
|
+
|
|
5
|
+
Released on July 19th, 2024.
|
|
6
|
+
|
|
7
|
+
- Fixed a bug where `es-toolkit/compat` was not available in modern Node.js environments.
|
|
8
|
+
- Added support for [max](https://es-toolkit.slash.page/reference/compat/math/max.html) and [min](https://es-toolkit.slash.page/reference/compat/math/min.html) in our compatibility layer `es-toolkit/compat`. ([e1e6e38](https://github.com/toss/es-toolkit/commit/e1e6e38206750fb90f5b99cace9196635288e21c))
|
|
9
|
+
|
|
3
10
|
## Version v1.11.0
|
|
4
11
|
|
|
5
12
|
Released on July 18th, 2024.
|
package/dist/array/index.mjs
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import "../chunk-DDH7K4QM.mjs";
|
|
2
|
+
import {
|
|
3
|
+
zipWith
|
|
4
|
+
} from "../chunk-4KYXHZ4R.mjs";
|
|
5
|
+
import {
|
|
6
|
+
unzip
|
|
7
|
+
} from "../chunk-UYZKMBDO.mjs";
|
|
8
|
+
import {
|
|
9
|
+
unzipWith
|
|
10
|
+
} from "../chunk-IFNXROZR.mjs";
|
|
2
11
|
import {
|
|
3
12
|
without
|
|
4
13
|
} from "../chunk-PYEYV7BY.mjs";
|
|
@@ -18,8 +27,11 @@ import {
|
|
|
18
27
|
zipObject
|
|
19
28
|
} from "../chunk-6GWEY5EL.mjs";
|
|
20
29
|
import {
|
|
21
|
-
|
|
22
|
-
} from "../chunk-
|
|
30
|
+
takeWhile
|
|
31
|
+
} from "../chunk-2IXFGSUA.mjs";
|
|
32
|
+
import {
|
|
33
|
+
toFilled
|
|
34
|
+
} from "../chunk-OP4OAKQJ.mjs";
|
|
23
35
|
import {
|
|
24
36
|
union
|
|
25
37
|
} from "../chunk-R6QA7PLZ.mjs";
|
|
@@ -39,11 +51,11 @@ import {
|
|
|
39
51
|
uniqWith
|
|
40
52
|
} from "../chunk-237HGSZS.mjs";
|
|
41
53
|
import {
|
|
42
|
-
|
|
43
|
-
} from "../chunk-
|
|
54
|
+
partition
|
|
55
|
+
} from "../chunk-DN3NOZ3H.mjs";
|
|
44
56
|
import {
|
|
45
|
-
|
|
46
|
-
} from "../chunk-
|
|
57
|
+
sample
|
|
58
|
+
} from "../chunk-2KNLZB7V.mjs";
|
|
47
59
|
import {
|
|
48
60
|
sampleSize
|
|
49
61
|
} from "../chunk-EHSKB6DF.mjs";
|
|
@@ -65,11 +77,11 @@ import {
|
|
|
65
77
|
takeRightWhile
|
|
66
78
|
} from "../chunk-NTLX2MPV.mjs";
|
|
67
79
|
import {
|
|
68
|
-
|
|
69
|
-
} from "../chunk-
|
|
80
|
+
intersection
|
|
81
|
+
} from "../chunk-FVVSE2F2.mjs";
|
|
70
82
|
import {
|
|
71
|
-
|
|
72
|
-
} from "../chunk-
|
|
83
|
+
intersectionBy
|
|
84
|
+
} from "../chunk-O6UXZR3U.mjs";
|
|
73
85
|
import {
|
|
74
86
|
intersectionWith
|
|
75
87
|
} from "../chunk-XI7KRD2C.mjs";
|
|
@@ -89,14 +101,14 @@ import {
|
|
|
89
101
|
orderBy
|
|
90
102
|
} from "../chunk-7B7W36UP.mjs";
|
|
91
103
|
import {
|
|
92
|
-
|
|
93
|
-
} from "../chunk-
|
|
94
|
-
import {
|
|
95
|
-
sample
|
|
96
|
-
} from "../chunk-2KNLZB7V.mjs";
|
|
104
|
+
flatMap
|
|
105
|
+
} from "../chunk-UY76KTPE.mjs";
|
|
97
106
|
import {
|
|
98
107
|
flattenDeep
|
|
99
108
|
} from "../chunk-ML727RRJ.mjs";
|
|
109
|
+
import {
|
|
110
|
+
flatten
|
|
111
|
+
} from "../chunk-33MSBDC6.mjs";
|
|
100
112
|
import {
|
|
101
113
|
forEachRight
|
|
102
114
|
} from "../chunk-IEA53J7P.mjs";
|
|
@@ -110,11 +122,11 @@ import {
|
|
|
110
122
|
initial
|
|
111
123
|
} from "../chunk-XPSOKBRZ.mjs";
|
|
112
124
|
import {
|
|
113
|
-
|
|
114
|
-
} from "../chunk-
|
|
125
|
+
difference
|
|
126
|
+
} from "../chunk-JPUKH67K.mjs";
|
|
115
127
|
import {
|
|
116
|
-
|
|
117
|
-
} from "../chunk-
|
|
128
|
+
differenceBy
|
|
129
|
+
} from "../chunk-LVWX5B43.mjs";
|
|
118
130
|
import {
|
|
119
131
|
differenceWith
|
|
120
132
|
} from "../chunk-6NVQAHXP.mjs";
|
|
@@ -133,12 +145,6 @@ import {
|
|
|
133
145
|
import {
|
|
134
146
|
fill
|
|
135
147
|
} from "../chunk-YFN6KOC4.mjs";
|
|
136
|
-
import {
|
|
137
|
-
flatMap
|
|
138
|
-
} from "../chunk-UY76KTPE.mjs";
|
|
139
|
-
import {
|
|
140
|
-
flatten
|
|
141
|
-
} from "../chunk-33MSBDC6.mjs";
|
|
142
148
|
import {
|
|
143
149
|
chunk
|
|
144
150
|
} from "../chunk-E6C5EZQA.mjs";
|
|
@@ -148,12 +154,6 @@ import {
|
|
|
148
154
|
import {
|
|
149
155
|
countBy
|
|
150
156
|
} from "../chunk-CRSKT4WW.mjs";
|
|
151
|
-
import {
|
|
152
|
-
difference
|
|
153
|
-
} from "../chunk-JPUKH67K.mjs";
|
|
154
|
-
import {
|
|
155
|
-
differenceBy
|
|
156
|
-
} from "../chunk-LVWX5B43.mjs";
|
|
157
157
|
import "../chunk-424M7IR7.mjs";
|
|
158
158
|
export {
|
|
159
159
|
chunk,
|
package/dist/compat/index.d.mts
CHANGED
|
@@ -465,4 +465,36 @@ declare const startsWith: (str: string, target: string, position?: number) => bo
|
|
|
465
465
|
*/
|
|
466
466
|
declare const endsWith: (str: string, target: string, position?: number) => boolean;
|
|
467
467
|
|
|
468
|
-
|
|
468
|
+
/**
|
|
469
|
+
* Finds the element in an array that has the maximum value.
|
|
470
|
+
*
|
|
471
|
+
* @template T - The type of elements in the array.
|
|
472
|
+
* @param {T[]} items The array of elements to search.
|
|
473
|
+
* @returns {T} The element with the maximum value.
|
|
474
|
+
* @example
|
|
475
|
+
* // Returns 9
|
|
476
|
+
* max([3, 1, 4, 1, 5, 9])
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* // Returns 8
|
|
480
|
+
* max([0, -3, 2, 8, 7])
|
|
481
|
+
*/
|
|
482
|
+
declare function max<T>(items?: readonly T[]): T;
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Finds the element in an array that has the minimum value.
|
|
486
|
+
*
|
|
487
|
+
* @template T - The type of elements in the array.
|
|
488
|
+
* @param {T[]} items The array of elements to search.
|
|
489
|
+
* @returns {T} The element with the minimum value.
|
|
490
|
+
* @example
|
|
491
|
+
* // Returns 1
|
|
492
|
+
* min([3, 1, 4, 1, 5, 9])
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
* // Returns -3
|
|
496
|
+
* min([0, -3, 2, 8, 7])
|
|
497
|
+
*/
|
|
498
|
+
declare function min<T>(items?: readonly T[]): T;
|
|
499
|
+
|
|
500
|
+
export { chunk, endsWith, get, max, min, set, startsWith, zipObjectDeep };
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -465,4 +465,36 @@ declare const startsWith: (str: string, target: string, position?: number) => bo
|
|
|
465
465
|
*/
|
|
466
466
|
declare const endsWith: (str: string, target: string, position?: number) => boolean;
|
|
467
467
|
|
|
468
|
-
|
|
468
|
+
/**
|
|
469
|
+
* Finds the element in an array that has the maximum value.
|
|
470
|
+
*
|
|
471
|
+
* @template T - The type of elements in the array.
|
|
472
|
+
* @param {T[]} items The array of elements to search.
|
|
473
|
+
* @returns {T} The element with the maximum value.
|
|
474
|
+
* @example
|
|
475
|
+
* // Returns 9
|
|
476
|
+
* max([3, 1, 4, 1, 5, 9])
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* // Returns 8
|
|
480
|
+
* max([0, -3, 2, 8, 7])
|
|
481
|
+
*/
|
|
482
|
+
declare function max<T>(items?: readonly T[]): T;
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Finds the element in an array that has the minimum value.
|
|
486
|
+
*
|
|
487
|
+
* @template T - The type of elements in the array.
|
|
488
|
+
* @param {T[]} items The array of elements to search.
|
|
489
|
+
* @returns {T} The element with the minimum value.
|
|
490
|
+
* @example
|
|
491
|
+
* // Returns 1
|
|
492
|
+
* min([3, 1, 4, 1, 5, 9])
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
* // Returns -3
|
|
496
|
+
* min([0, -3, 2, 8, 7])
|
|
497
|
+
*/
|
|
498
|
+
declare function min<T>(items?: readonly T[]): T;
|
|
499
|
+
|
|
500
|
+
export { chunk, endsWith, get, max, min, set, startsWith, zipObjectDeep };
|
package/dist/compat/index.js
CHANGED
|
@@ -96,9 +96,11 @@ __export(compat_exports, {
|
|
|
96
96
|
keyBy: () => keyBy,
|
|
97
97
|
last: () => last,
|
|
98
98
|
lowerCase: () => lowerCase,
|
|
99
|
+
max: () => max,
|
|
99
100
|
maxBy: () => maxBy,
|
|
100
101
|
mean: () => mean,
|
|
101
102
|
meanBy: () => meanBy,
|
|
103
|
+
min: () => min,
|
|
102
104
|
minBy: () => minBy,
|
|
103
105
|
negate: () => negate,
|
|
104
106
|
noop: () => noop,
|
|
@@ -338,11 +340,11 @@ function keyBy(arr, getKeyFromItem) {
|
|
|
338
340
|
// src/array/maxBy.ts
|
|
339
341
|
function maxBy(items, getValue) {
|
|
340
342
|
let maxElement = items[0];
|
|
341
|
-
let
|
|
343
|
+
let max2 = -Infinity;
|
|
342
344
|
for (const element of items) {
|
|
343
345
|
const value = getValue(element);
|
|
344
|
-
if (value >
|
|
345
|
-
|
|
346
|
+
if (value > max2) {
|
|
347
|
+
max2 = value;
|
|
346
348
|
maxElement = element;
|
|
347
349
|
}
|
|
348
350
|
}
|
|
@@ -352,11 +354,11 @@ function maxBy(items, getValue) {
|
|
|
352
354
|
// src/array/minBy.ts
|
|
353
355
|
function minBy(items, getValue) {
|
|
354
356
|
let minElement = items[0];
|
|
355
|
-
let
|
|
357
|
+
let min2 = Infinity;
|
|
356
358
|
for (const element of items) {
|
|
357
359
|
const value = getValue(element);
|
|
358
|
-
if (value <
|
|
359
|
-
|
|
360
|
+
if (value < min2) {
|
|
361
|
+
min2 = value;
|
|
360
362
|
minElement = element;
|
|
361
363
|
}
|
|
362
364
|
}
|
|
@@ -1204,6 +1206,32 @@ var startsWith = (str, target, position = 0) => {
|
|
|
1204
1206
|
var endsWith = (str, target, position = str.length) => {
|
|
1205
1207
|
return str.endsWith(target, position);
|
|
1206
1208
|
};
|
|
1209
|
+
|
|
1210
|
+
// src/compat/math/max.ts
|
|
1211
|
+
function max(items = []) {
|
|
1212
|
+
let maxElement = items[0];
|
|
1213
|
+
let max2 = void 0;
|
|
1214
|
+
for (const element of items) {
|
|
1215
|
+
if (max2 == null || element > max2) {
|
|
1216
|
+
max2 = element;
|
|
1217
|
+
maxElement = element;
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
return maxElement;
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
// src/compat/math/min.ts
|
|
1224
|
+
function min(items = []) {
|
|
1225
|
+
let minElement = items[0];
|
|
1226
|
+
let min2 = void 0;
|
|
1227
|
+
for (const element of items) {
|
|
1228
|
+
if (min2 == null || element < min2) {
|
|
1229
|
+
min2 = element;
|
|
1230
|
+
minElement = element;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
return minElement;
|
|
1234
|
+
}
|
|
1207
1235
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1208
1236
|
0 && (module.exports = {
|
|
1209
1237
|
AbortError,
|
|
@@ -1248,9 +1276,11 @@ var endsWith = (str, target, position = str.length) => {
|
|
|
1248
1276
|
keyBy,
|
|
1249
1277
|
last,
|
|
1250
1278
|
lowerCase,
|
|
1279
|
+
max,
|
|
1251
1280
|
maxBy,
|
|
1252
1281
|
mean,
|
|
1253
1282
|
meanBy,
|
|
1283
|
+
min,
|
|
1254
1284
|
minBy,
|
|
1255
1285
|
negate,
|
|
1256
1286
|
noop,
|