es-toolkit 1.20.0 → 1.21.0-dev.660
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 +13 -0
- package/dist/_chunk/{isWeakSet-E_VMwB.js → isWeakSet-1xFSnK.js} +5 -0
- package/dist/_chunk/{toMerged-Bzkqyz.js → toMerged-D-sLFv.js} +10 -8
- package/dist/_chunk/{zipWith-CDtN9Y.js → zipWith-DEcUS4.js} +25 -12
- package/dist/array/compact.d.mts +4 -4
- package/dist/array/compact.d.ts +4 -4
- package/dist/array/compact.mjs +2 -1
- package/dist/array/countBy.mjs +2 -1
- package/dist/array/flatten.mjs +2 -1
- package/dist/array/groupBy.mjs +2 -1
- package/dist/array/index.js +1 -1
- package/dist/array/keyBy.mjs +2 -1
- package/dist/array/maxBy.d.mts +16 -0
- package/dist/array/maxBy.d.ts +16 -0
- package/dist/array/maxBy.mjs +2 -1
- package/dist/array/minBy.d.mts +16 -0
- package/dist/array/minBy.d.ts +16 -0
- package/dist/array/minBy.mjs +2 -1
- package/dist/array/partition.mjs +2 -1
- package/dist/array/takeWhile.mjs +2 -1
- package/dist/array/unionBy.mjs +3 -1
- package/dist/array/uniqBy.mjs +2 -1
- package/dist/array/uniqWith.mjs +2 -1
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/array/castArray.d.mts +2 -2
- package/dist/compat/array/castArray.d.ts +2 -2
- package/dist/compat/array/flatten.mjs +2 -1
- package/dist/compat/function/curry.mjs +26 -34
- package/dist/compat/function/defer.d.mts +16 -0
- package/dist/compat/function/defer.d.ts +16 -0
- package/dist/compat/function/defer.mjs +8 -0
- package/dist/compat/index.d.mts +13 -5
- package/dist/compat/index.d.ts +13 -5
- package/dist/compat/index.js +200 -71
- package/dist/compat/index.mjs +14 -6
- package/dist/compat/math/inRange.d.mts +27 -0
- package/dist/compat/math/inRange.d.ts +27 -0
- package/dist/compat/math/inRange.mjs +28 -0
- package/dist/compat/math/max.mjs +2 -1
- package/dist/compat/math/min.mjs +2 -1
- package/dist/compat/math/random.d.mts +50 -0
- package/dist/compat/math/random.d.ts +50 -0
- package/dist/compat/math/random.mjs +70 -0
- package/dist/compat/object/cloneDeep.d.mts +49 -0
- package/dist/compat/object/cloneDeep.d.ts +49 -0
- package/dist/compat/object/pick.mjs +2 -1
- package/dist/compat/predicate/conformsTo.mjs +3 -1
- package/dist/compat/predicate/isArrayLikeObject.d.mts +15 -0
- package/dist/compat/predicate/isArrayLikeObject.d.ts +15 -0
- package/dist/compat/predicate/isArrayLikeObject.mjs +8 -0
- package/dist/compat/predicate/isBoolean.d.mts +3 -3
- package/dist/compat/predicate/isBoolean.d.ts +3 -3
- package/dist/compat/predicate/isBoolean.mjs +2 -10
- package/dist/compat/predicate/isError.d.mts +16 -0
- package/dist/compat/predicate/isError.d.ts +16 -0
- package/dist/compat/predicate/isError.mjs +7 -0
- package/dist/compat/predicate/isFinite.d.mts +20 -0
- package/dist/compat/predicate/isFinite.d.ts +20 -0
- package/dist/compat/predicate/isFinite.mjs +5 -0
- package/dist/compat/predicate/isNil.d.mts +22 -0
- package/dist/compat/predicate/isNil.d.ts +22 -0
- package/dist/compat/predicate/isNumber.mjs +1 -6
- package/dist/compat/predicate/isRegExp.mjs +2 -2
- package/dist/compat/predicate/isString.d.mts +1 -1
- package/dist/compat/predicate/isString.d.ts +1 -1
- package/dist/compat/predicate/isString.mjs +1 -9
- package/dist/compat/predicate/isSymbol.mjs +1 -1
- package/dist/compat/string/pad.d.mts +19 -0
- package/dist/compat/string/pad.d.ts +19 -0
- package/dist/compat/string/pad.mjs +8 -0
- package/dist/compat/string/padEnd.mjs +3 -1
- package/dist/compat/string/padStart.mjs +3 -1
- package/dist/compat/util/toFinite.d.mts +17 -0
- package/dist/compat/util/toFinite.d.ts +17 -0
- package/dist/compat/util/toFinite.mjs +15 -0
- package/dist/compat/util/toInteger.d.mts +17 -0
- package/dist/compat/util/toInteger.d.ts +17 -0
- package/dist/compat/util/toInteger.mjs +9 -0
- package/dist/compat/util/toNumber.d.mts +19 -0
- package/dist/compat/util/toNumber.d.ts +19 -0
- package/dist/compat/util/toNumber.mjs +10 -0
- package/dist/function/curry.d.mts +18 -19
- package/dist/function/curry.d.ts +18 -19
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +10 -8
- package/dist/index.mjs +2 -0
- package/dist/math/random.d.mts +1 -1
- package/dist/math/random.d.ts +1 -1
- package/dist/math/range.d.mts +7 -25
- package/dist/math/range.d.ts +7 -25
- package/dist/object/index.js +8 -4
- package/dist/object/omit.d.mts +1 -1
- package/dist/object/omit.d.ts +1 -1
- package/dist/object/omit.mjs +2 -1
- package/dist/object/omitBy.mjs +5 -4
- package/dist/object/pick.mjs +5 -2
- package/dist/object/pickBy.mjs +5 -4
- package/dist/predicate/index.d.mts +1 -0
- package/dist/predicate/index.d.ts +1 -0
- package/dist/predicate/index.js +5 -4
- package/dist/predicate/index.mjs +1 -0
- package/dist/predicate/isError.d.mts +16 -0
- package/dist/predicate/isError.d.ts +16 -0
- package/dist/predicate/isError.mjs +5 -0
- package/dist/promise/withTimeout.d.mts +8 -2
- package/dist/promise/withTimeout.d.ts +8 -2
- package/dist/string/_internal/getWords.mjs +1 -1
- package/dist/string/camelCase.d.mts +1 -0
- package/dist/string/camelCase.d.ts +1 -0
- package/dist/string/constantCase.d.mts +17 -0
- package/dist/string/constantCase.d.ts +17 -0
- package/dist/string/constantCase.mjs +8 -0
- package/dist/string/index.d.mts +1 -0
- package/dist/string/index.d.ts +1 -0
- package/dist/string/index.js +10 -8
- package/dist/string/index.mjs +1 -0
- package/dist/string/startCase.d.mts +1 -1
- package/dist/string/startCase.d.ts +1 -1
- package/dist/string/startCase.mjs +3 -7
- package/dist/string/trimStart.d.mts +1 -1
- package/dist/string/trimStart.d.ts +1 -1
- package/dist/string/upperFirst.d.mts +3 -3
- package/dist/string/upperFirst.d.ts +3 -3
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# es-toolkit Changelog
|
|
2
2
|
|
|
3
|
+
## Version v1.21.0
|
|
4
|
+
|
|
5
|
+
Released on September 25th, 2024.
|
|
6
|
+
|
|
7
|
+
- Added support for [constantCase](https://es-toolkit.slash.page/reference/string/constantCase.html) and [isError](https://es-toolkit.slash.page/reference/predicate/isError.html).
|
|
8
|
+
- Added compatibility functions for [pad](https://es-toolkit.slash.page/reference/compat/string/pad.html), [padStart](https://es-toolkit.slash.page/reference/compat/string/padStart.html), [padEnd](https://es-toolkit.slash.page/reference/compat/string/padEnd.html), [defer](https://es-toolkit.slash.page/reference/compat/function/defer.html), [isFinite](https://es-toolkit.slash.page/reference/compat/predicate/isFinite.html), [toNumber](https://es-toolkit.slash.page/reference/compat/math/toNumber.html), [toFinite](https://es-toolkit.slash.page/reference/compat/math/toFinite.html), and [toInteger](https://es-toolkit.slash.page/reference/compat/math/toInteger.html).
|
|
9
|
+
- Improved performance for [flatten](https://es-toolkit.slash.page/reference/array/flatten.html), [isNumber](https://es-toolkit.slash.page/reference/predicate/isNumber.html), [isString](https://es-toolkit.slash.page/reference/predicate/isString.html), [isSymbol](https://es-toolkit.slash.page/reference/predicate/isSymbol.html), [isRegExp](https://es-toolkit.slash.page/reference/predicate/isRegExp.html), and [isBoolean](https://es-toolkit.slash.page/reference/predicate/isBoolean.html).
|
|
10
|
+
- Fixed [compact](https://es-toolkit.slash.page/reference/array/compact.html) to correctly exclude `0n` as a falsey value.
|
|
11
|
+
- Fixed [pick](https://es-toolkit.slash.page/reference/object/pick.html) to not pick nonexistent keys from the original object.
|
|
12
|
+
- Fixed [omit](https://es-toolkit.slash.page/reference/object/omit.html) to accept readonly arrays.
|
|
13
|
+
|
|
14
|
+
This version includes contributions from @hyesungoh, @D-Sketon, @mass2527, @gweesin, @VVSOGI, @coding-honey, @seonghun0828, and @jsparkdev. Thank you for your valuable contributions!
|
|
15
|
+
|
|
3
16
|
## Version v1.20.0
|
|
4
17
|
|
|
5
18
|
Released on September 20th, 2024.
|
|
@@ -238,6 +238,10 @@ function isFunction(value) {
|
|
|
238
238
|
return typeof value === 'function';
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
+
function isRegExp(value) {
|
|
242
|
+
return value instanceof RegExp;
|
|
243
|
+
}
|
|
244
|
+
|
|
241
245
|
function isWeakMap(value) {
|
|
242
246
|
return value instanceof WeakMap;
|
|
243
247
|
}
|
|
@@ -257,6 +261,7 @@ exports.isLength = isLength;
|
|
|
257
261
|
exports.isNil = isNil;
|
|
258
262
|
exports.isNotNil = isNotNil;
|
|
259
263
|
exports.isNull = isNull;
|
|
264
|
+
exports.isRegExp = isRegExp;
|
|
260
265
|
exports.isUndefined = isUndefined;
|
|
261
266
|
exports.isWeakMap = isWeakMap;
|
|
262
267
|
exports.isWeakSet = isWeakSet;
|
|
@@ -4,22 +4,24 @@ const isPlainObject = require('./isPlainObject-BIekvL.js');
|
|
|
4
4
|
|
|
5
5
|
function omitBy(obj, shouldOmit) {
|
|
6
6
|
const result = {};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const objEntries = Object.entries(obj);
|
|
8
|
+
for (let i = 0; i < objEntries.length; i++) {
|
|
9
|
+
const [key, value] = objEntries[i];
|
|
10
|
+
if (!shouldOmit(value, key)) {
|
|
11
|
+
result[key] = value;
|
|
10
12
|
}
|
|
11
|
-
result[key] = value;
|
|
12
13
|
}
|
|
13
14
|
return result;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
function pickBy(obj, shouldPick) {
|
|
17
18
|
const result = {};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const objEntries = Object.entries(obj);
|
|
20
|
+
for (let i = 0; i < objEntries.length; i++) {
|
|
21
|
+
const [key, value] = objEntries[i];
|
|
22
|
+
if (shouldPick(value, key)) {
|
|
23
|
+
result[key] = value;
|
|
21
24
|
}
|
|
22
|
-
result[key] = value;
|
|
23
25
|
}
|
|
24
26
|
return result;
|
|
25
27
|
}
|
|
@@ -27,7 +27,8 @@ function chunk(arr, size) {
|
|
|
27
27
|
|
|
28
28
|
function compact(arr) {
|
|
29
29
|
const result = [];
|
|
30
|
-
for (
|
|
30
|
+
for (let i = 0; i < arr.length; i++) {
|
|
31
|
+
const item = arr[i];
|
|
31
32
|
if (item) {
|
|
32
33
|
result.push(item);
|
|
33
34
|
}
|
|
@@ -37,7 +38,8 @@ function compact(arr) {
|
|
|
37
38
|
|
|
38
39
|
function countBy(arr, mapper) {
|
|
39
40
|
const result = {};
|
|
40
|
-
for (
|
|
41
|
+
for (let i = 0; i < arr.length; i++) {
|
|
42
|
+
const item = arr[i];
|
|
41
43
|
const key = mapper(item);
|
|
42
44
|
result[key] = (result[key] ?? 0) + 1;
|
|
43
45
|
}
|
|
@@ -103,7 +105,8 @@ function flatten(arr, depth = 1) {
|
|
|
103
105
|
const result = [];
|
|
104
106
|
const flooredDepth = Math.floor(depth);
|
|
105
107
|
const recursive = (arr, currentDepth) => {
|
|
106
|
-
for (
|
|
108
|
+
for (let i = 0; i < arr.length; i++) {
|
|
109
|
+
const item = arr[i];
|
|
107
110
|
if (Array.isArray(item) && currentDepth < flooredDepth) {
|
|
108
111
|
recursive(item, currentDepth + 1);
|
|
109
112
|
}
|
|
@@ -137,7 +140,8 @@ function forEachRight(arr, callback) {
|
|
|
137
140
|
|
|
138
141
|
function groupBy(arr, getKeyFromItem) {
|
|
139
142
|
const result = Object.create(null);
|
|
140
|
-
for (
|
|
143
|
+
for (let i = 0; i < arr.length; i++) {
|
|
144
|
+
const item = arr[i];
|
|
141
145
|
const key = getKeyFromItem(item);
|
|
142
146
|
if (result[key] == null) {
|
|
143
147
|
result[key] = [];
|
|
@@ -181,7 +185,8 @@ function isSubset(superset, subset) {
|
|
|
181
185
|
|
|
182
186
|
function keyBy(arr, getKeyFromItem) {
|
|
183
187
|
const result = {};
|
|
184
|
-
for (
|
|
188
|
+
for (let i = 0; i < arr.length; i++) {
|
|
189
|
+
const item = arr[i];
|
|
185
190
|
const key = getKeyFromItem(item);
|
|
186
191
|
result[key] = item;
|
|
187
192
|
}
|
|
@@ -195,7 +200,8 @@ function last(arr) {
|
|
|
195
200
|
function maxBy(items, getValue) {
|
|
196
201
|
let maxElement = items[0];
|
|
197
202
|
let max = -Infinity;
|
|
198
|
-
for (
|
|
203
|
+
for (let i = 0; i < items.length; i++) {
|
|
204
|
+
const element = items[i];
|
|
199
205
|
const value = getValue(element);
|
|
200
206
|
if (value > max) {
|
|
201
207
|
max = value;
|
|
@@ -208,7 +214,8 @@ function maxBy(items, getValue) {
|
|
|
208
214
|
function minBy(items, getValue) {
|
|
209
215
|
let minElement = items[0];
|
|
210
216
|
let min = Infinity;
|
|
211
|
-
for (
|
|
217
|
+
for (let i = 0; i < items.length; i++) {
|
|
218
|
+
const element = items[i];
|
|
212
219
|
const value = getValue(element);
|
|
213
220
|
if (value < min) {
|
|
214
221
|
min = value;
|
|
@@ -221,7 +228,8 @@ function minBy(items, getValue) {
|
|
|
221
228
|
function partition(arr, isInTruthy) {
|
|
222
229
|
const truthy = [];
|
|
223
230
|
const falsy = [];
|
|
224
|
-
for (
|
|
231
|
+
for (let i = 0; i < arr.length; i++) {
|
|
232
|
+
const item = arr[i];
|
|
225
233
|
if (isInTruthy(item)) {
|
|
226
234
|
truthy.push(item);
|
|
227
235
|
}
|
|
@@ -298,7 +306,8 @@ function takeRightWhile(arr, shouldContinueTaking) {
|
|
|
298
306
|
|
|
299
307
|
function takeWhile(arr, shouldContinueTaking) {
|
|
300
308
|
const result = [];
|
|
301
|
-
for (
|
|
309
|
+
for (let i = 0; i < arr.length; i++) {
|
|
310
|
+
const item = arr[i];
|
|
302
311
|
if (!shouldContinueTaking(item)) {
|
|
303
312
|
break;
|
|
304
313
|
}
|
|
@@ -328,7 +337,9 @@ function union(arr1, arr2) {
|
|
|
328
337
|
|
|
329
338
|
function unionBy(arr1, arr2, mapper) {
|
|
330
339
|
const map = new Map();
|
|
331
|
-
|
|
340
|
+
const items = [...arr1, ...arr2];
|
|
341
|
+
for (let i = 0; i < items.length; i++) {
|
|
342
|
+
const item = items[i];
|
|
332
343
|
const key = mapper(item);
|
|
333
344
|
if (!map.has(key)) {
|
|
334
345
|
map.set(key, item);
|
|
@@ -339,7 +350,8 @@ function unionBy(arr1, arr2, mapper) {
|
|
|
339
350
|
|
|
340
351
|
function uniqWith(arr, areItemsEqual) {
|
|
341
352
|
const result = [];
|
|
342
|
-
for (
|
|
353
|
+
for (let i = 0; i < arr.length; i++) {
|
|
354
|
+
const item = arr[i];
|
|
343
355
|
const isUniq = result.every(v => !areItemsEqual(v, item));
|
|
344
356
|
if (isUniq) {
|
|
345
357
|
result.push(item);
|
|
@@ -354,7 +366,8 @@ function unionWith(arr1, arr2, areItemsEqual) {
|
|
|
354
366
|
|
|
355
367
|
function uniqBy(arr, mapper) {
|
|
356
368
|
const map = new Map();
|
|
357
|
-
for (
|
|
369
|
+
for (let i = 0; i < arr.length; i++) {
|
|
370
|
+
const item = arr[i];
|
|
358
371
|
const key = mapper(item);
|
|
359
372
|
if (!map.has(key)) {
|
|
360
373
|
map.set(key, item);
|
package/dist/array/compact.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
type NotFalsey<T> = Exclude<T, false | null | 0 | '' | undefined>;
|
|
1
|
+
type NotFalsey<T> = Exclude<T, false | null | 0 | 0n | '' | undefined>;
|
|
2
2
|
/**
|
|
3
|
-
* Removes falsey values (false, null, 0, '', undefined, NaN) from an array.
|
|
3
|
+
* Removes falsey values (false, null, 0, 0n, '', undefined, NaN) from an array.
|
|
4
4
|
*
|
|
5
5
|
* @template T - The type of elements in the array.
|
|
6
6
|
* @param {T[]} arr - The input array to remove falsey values.
|
|
7
|
-
* @returns {Array<Exclude<T, false | null | 0 | '' | undefined>>} - A new array with all falsey values removed.
|
|
7
|
+
* @returns {Array<Exclude<T, false | null | 0 | 0n | '' | undefined>>} - A new array with all falsey values removed.
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
|
-
* compact([0, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);
|
|
10
|
+
* compact([0, 0n, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);
|
|
11
11
|
* Returns: [1, 2, 3, 4, 5]
|
|
12
12
|
*/
|
|
13
13
|
declare function compact<T>(arr: readonly T[]): Array<NotFalsey<T>>;
|
package/dist/array/compact.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
type NotFalsey<T> = Exclude<T, false | null | 0 | '' | undefined>;
|
|
1
|
+
type NotFalsey<T> = Exclude<T, false | null | 0 | 0n | '' | undefined>;
|
|
2
2
|
/**
|
|
3
|
-
* Removes falsey values (false, null, 0, '', undefined, NaN) from an array.
|
|
3
|
+
* Removes falsey values (false, null, 0, 0n, '', undefined, NaN) from an array.
|
|
4
4
|
*
|
|
5
5
|
* @template T - The type of elements in the array.
|
|
6
6
|
* @param {T[]} arr - The input array to remove falsey values.
|
|
7
|
-
* @returns {Array<Exclude<T, false | null | 0 | '' | undefined>>} - A new array with all falsey values removed.
|
|
7
|
+
* @returns {Array<Exclude<T, false | null | 0 | 0n | '' | undefined>>} - A new array with all falsey values removed.
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
|
-
* compact([0, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);
|
|
10
|
+
* compact([0, 0n, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);
|
|
11
11
|
* Returns: [1, 2, 3, 4, 5]
|
|
12
12
|
*/
|
|
13
13
|
declare function compact<T>(arr: readonly T[]): Array<NotFalsey<T>>;
|
package/dist/array/compact.mjs
CHANGED
package/dist/array/countBy.mjs
CHANGED
package/dist/array/flatten.mjs
CHANGED
|
@@ -2,7 +2,8 @@ function flatten(arr, depth = 1) {
|
|
|
2
2
|
const result = [];
|
|
3
3
|
const flooredDepth = Math.floor(depth);
|
|
4
4
|
const recursive = (arr, currentDepth) => {
|
|
5
|
-
for (
|
|
5
|
+
for (let i = 0; i < arr.length; i++) {
|
|
6
|
+
const item = arr[i];
|
|
6
7
|
if (Array.isArray(item) && currentDepth < flooredDepth) {
|
|
7
8
|
recursive(item, currentDepth + 1);
|
|
8
9
|
}
|
package/dist/array/groupBy.mjs
CHANGED
package/dist/array/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const zipWith = require('../_chunk/zipWith-
|
|
5
|
+
const zipWith = require('../_chunk/zipWith-DEcUS4.js');
|
|
6
6
|
|
|
7
7
|
function drop(arr, itemsCount) {
|
|
8
8
|
itemsCount = Math.max(itemsCount, 0);
|
package/dist/array/keyBy.mjs
CHANGED
package/dist/array/maxBy.d.mts
CHANGED
|
@@ -9,6 +9,14 @@
|
|
|
9
9
|
* @example
|
|
10
10
|
* maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }
|
|
11
11
|
* maxBy([], x => x.a); // Returns: undefined
|
|
12
|
+
* maxBy(
|
|
13
|
+
* [
|
|
14
|
+
* { name: 'john', age: 30 },
|
|
15
|
+
* { name: 'jane', age: 28 },
|
|
16
|
+
* { name: 'joe', age: 26 },
|
|
17
|
+
* ],
|
|
18
|
+
* x => x.age
|
|
19
|
+
* ); // Returns: { name: 'john', age: 30 }
|
|
12
20
|
*/
|
|
13
21
|
declare function maxBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
|
|
14
22
|
/**
|
|
@@ -22,6 +30,14 @@ declare function maxBy<T>(items: readonly [T, ...T[]], getValue: (element: T) =>
|
|
|
22
30
|
* @example
|
|
23
31
|
* maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }
|
|
24
32
|
* maxBy([], x => x.a); // Returns: undefined
|
|
33
|
+
* maxBy(
|
|
34
|
+
* [
|
|
35
|
+
* { name: 'john', age: 30 },
|
|
36
|
+
* { name: 'jane', age: 28 },
|
|
37
|
+
* { name: 'joe', age: 26 },
|
|
38
|
+
* ],
|
|
39
|
+
* x => x.age
|
|
40
|
+
* ); // Returns: { name: 'john', age: 30 }
|
|
25
41
|
*/
|
|
26
42
|
declare function maxBy<T>(items: readonly T[], getValue: (element: T) => number): T | undefined;
|
|
27
43
|
|
package/dist/array/maxBy.d.ts
CHANGED
|
@@ -9,6 +9,14 @@
|
|
|
9
9
|
* @example
|
|
10
10
|
* maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }
|
|
11
11
|
* maxBy([], x => x.a); // Returns: undefined
|
|
12
|
+
* maxBy(
|
|
13
|
+
* [
|
|
14
|
+
* { name: 'john', age: 30 },
|
|
15
|
+
* { name: 'jane', age: 28 },
|
|
16
|
+
* { name: 'joe', age: 26 },
|
|
17
|
+
* ],
|
|
18
|
+
* x => x.age
|
|
19
|
+
* ); // Returns: { name: 'john', age: 30 }
|
|
12
20
|
*/
|
|
13
21
|
declare function maxBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
|
|
14
22
|
/**
|
|
@@ -22,6 +30,14 @@ declare function maxBy<T>(items: readonly [T, ...T[]], getValue: (element: T) =>
|
|
|
22
30
|
* @example
|
|
23
31
|
* maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }
|
|
24
32
|
* maxBy([], x => x.a); // Returns: undefined
|
|
33
|
+
* maxBy(
|
|
34
|
+
* [
|
|
35
|
+
* { name: 'john', age: 30 },
|
|
36
|
+
* { name: 'jane', age: 28 },
|
|
37
|
+
* { name: 'joe', age: 26 },
|
|
38
|
+
* ],
|
|
39
|
+
* x => x.age
|
|
40
|
+
* ); // Returns: { name: 'john', age: 30 }
|
|
25
41
|
*/
|
|
26
42
|
declare function maxBy<T>(items: readonly T[], getValue: (element: T) => number): T | undefined;
|
|
27
43
|
|
package/dist/array/maxBy.mjs
CHANGED
package/dist/array/minBy.d.mts
CHANGED
|
@@ -9,6 +9,14 @@
|
|
|
9
9
|
* @example
|
|
10
10
|
* minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }
|
|
11
11
|
* minBy([], x => x.a); // Returns: undefined
|
|
12
|
+
* minBy(
|
|
13
|
+
* [
|
|
14
|
+
* { name: 'john', age: 30 },
|
|
15
|
+
* { name: 'jane', age: 28 },
|
|
16
|
+
* { name: 'joe', age: 26 },
|
|
17
|
+
* ],
|
|
18
|
+
* x => x.age
|
|
19
|
+
* ); // Returns: { name: 'joe', age: 26 }
|
|
12
20
|
*/
|
|
13
21
|
declare function minBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
|
|
14
22
|
/**
|
|
@@ -22,6 +30,14 @@ declare function minBy<T>(items: readonly [T, ...T[]], getValue: (element: T) =>
|
|
|
22
30
|
* @example
|
|
23
31
|
* minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }
|
|
24
32
|
* minBy([], x => x.a); // Returns: undefined
|
|
33
|
+
* minBy(
|
|
34
|
+
* [
|
|
35
|
+
* { name: 'john', age: 30 },
|
|
36
|
+
* { name: 'jane', age: 28 },
|
|
37
|
+
* { name: 'joe', age: 26 },
|
|
38
|
+
* ],
|
|
39
|
+
* x => x.age
|
|
40
|
+
* ); // Returns: { name: 'joe', age: 26 }
|
|
25
41
|
*/
|
|
26
42
|
declare function minBy<T>(items: readonly T[], getValue: (element: T) => number): T | undefined;
|
|
27
43
|
|
package/dist/array/minBy.d.ts
CHANGED
|
@@ -9,6 +9,14 @@
|
|
|
9
9
|
* @example
|
|
10
10
|
* minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }
|
|
11
11
|
* minBy([], x => x.a); // Returns: undefined
|
|
12
|
+
* minBy(
|
|
13
|
+
* [
|
|
14
|
+
* { name: 'john', age: 30 },
|
|
15
|
+
* { name: 'jane', age: 28 },
|
|
16
|
+
* { name: 'joe', age: 26 },
|
|
17
|
+
* ],
|
|
18
|
+
* x => x.age
|
|
19
|
+
* ); // Returns: { name: 'joe', age: 26 }
|
|
12
20
|
*/
|
|
13
21
|
declare function minBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
|
|
14
22
|
/**
|
|
@@ -22,6 +30,14 @@ declare function minBy<T>(items: readonly [T, ...T[]], getValue: (element: T) =>
|
|
|
22
30
|
* @example
|
|
23
31
|
* minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }
|
|
24
32
|
* minBy([], x => x.a); // Returns: undefined
|
|
33
|
+
* minBy(
|
|
34
|
+
* [
|
|
35
|
+
* { name: 'john', age: 30 },
|
|
36
|
+
* { name: 'jane', age: 28 },
|
|
37
|
+
* { name: 'joe', age: 26 },
|
|
38
|
+
* ],
|
|
39
|
+
* x => x.age
|
|
40
|
+
* ); // Returns: { name: 'joe', age: 26 }
|
|
25
41
|
*/
|
|
26
42
|
declare function minBy<T>(items: readonly T[], getValue: (element: T) => number): T | undefined;
|
|
27
43
|
|
package/dist/array/minBy.mjs
CHANGED
package/dist/array/partition.mjs
CHANGED
package/dist/array/takeWhile.mjs
CHANGED
package/dist/array/unionBy.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
function unionBy(arr1, arr2, mapper) {
|
|
2
2
|
const map = new Map();
|
|
3
|
-
|
|
3
|
+
const items = [...arr1, ...arr2];
|
|
4
|
+
for (let i = 0; i < items.length; i++) {
|
|
5
|
+
const item = items[i];
|
|
4
6
|
const key = mapper(item);
|
|
5
7
|
if (!map.has(key)) {
|
|
6
8
|
map.set(key, item);
|
package/dist/array/uniqBy.mjs
CHANGED
package/dist/array/uniqWith.mjs
CHANGED