es-toolkit 1.13.1-dev.364 → 1.13.1-dev.366
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/_chunk/size-CJyNw8.js +512 -0
- package/dist/array/index.js +53 -511
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/array/flattenDeep.d.mts +25 -0
- package/dist/compat/array/flattenDeep.d.ts +25 -0
- package/dist/compat/array/flattenDeep.mjs +7 -0
- package/dist/compat/array/flattenDepth.d.mts +19 -0
- package/dist/compat/array/flattenDepth.d.ts +19 -0
- package/dist/compat/array/flattenDepth.mjs +7 -0
- package/dist/compat/index.d.mts +2 -1
- package/dist/compat/index.d.ts +2 -1
- package/dist/compat/index.js +70 -61
- package/dist/compat/index.mjs +2 -1
- package/dist/index.js +54 -53
- package/dist/object/cloneDeep.mjs +2 -2
- package/dist/object/index.js +6 -6
- package/dist/predicate/index.js +4 -4
- package/package.json +1 -1
- package/dist/_chunk/{isPrimitive-BBs6Fb.js → isTypedArray-BBEkFl.js} +4 -4
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility type for recursively unpacking nested array types to extract the type of the innermost element
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ExtractNestedArrayType<(number | (number | number[])[])[]>
|
|
6
|
+
* // number
|
|
7
|
+
*
|
|
8
|
+
* ExtractNestedArrayType<(boolean | (string | number[])[])[]>
|
|
9
|
+
* // string | number | boolean
|
|
10
|
+
*/
|
|
11
|
+
type ExtractNestedArrayType<T> = T extends ReadonlyArray<infer U> ? ExtractNestedArrayType<U> : T;
|
|
12
|
+
/**
|
|
13
|
+
* Flattens all depths of a nested array.
|
|
14
|
+
*
|
|
15
|
+
* @template T - The type of elements within the array.
|
|
16
|
+
* @param {T[] | object} value - The value to flatten.
|
|
17
|
+
* @returns {Array<ExtractNestedArrayType<T>> | []} A new array that has been flattened.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const value = flattenDeep([1, [2, [3]], [4, [5, 6]]]);
|
|
21
|
+
* // Returns: [1, 2, 3, 4, 5, 6]
|
|
22
|
+
*/
|
|
23
|
+
declare function flattenDeep<T>(value: readonly T[] | object): Array<ExtractNestedArrayType<T>> | [];
|
|
24
|
+
|
|
25
|
+
export { flattenDeep };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility type for recursively unpacking nested array types to extract the type of the innermost element
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ExtractNestedArrayType<(number | (number | number[])[])[]>
|
|
6
|
+
* // number
|
|
7
|
+
*
|
|
8
|
+
* ExtractNestedArrayType<(boolean | (string | number[])[])[]>
|
|
9
|
+
* // string | number | boolean
|
|
10
|
+
*/
|
|
11
|
+
type ExtractNestedArrayType<T> = T extends ReadonlyArray<infer U> ? ExtractNestedArrayType<U> : T;
|
|
12
|
+
/**
|
|
13
|
+
* Flattens all depths of a nested array.
|
|
14
|
+
*
|
|
15
|
+
* @template T - The type of elements within the array.
|
|
16
|
+
* @param {T[] | object} value - The value to flatten.
|
|
17
|
+
* @returns {Array<ExtractNestedArrayType<T>> | []} A new array that has been flattened.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const value = flattenDeep([1, [2, [3]], [4, [5, 6]]]);
|
|
21
|
+
* // Returns: [1, 2, 3, 4, 5, 6]
|
|
22
|
+
*/
|
|
23
|
+
declare function flattenDeep<T>(value: readonly T[] | object): Array<ExtractNestedArrayType<T>> | [];
|
|
24
|
+
|
|
25
|
+
export { flattenDeep };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flattens an array up to the specified depth.
|
|
3
|
+
*
|
|
4
|
+
* @template T - The type of elements within the array.
|
|
5
|
+
* @template D - The depth to which the array should be flattened.
|
|
6
|
+
* @param {T[] | object} value - The value to flatten.
|
|
7
|
+
* @param {D} depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.
|
|
8
|
+
* @returns {Array<FlatArray<T[], D>> | []} A new array that has been flattened.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const arr = flatten([1, [2, 3], [4, [5, 6]]], 1);
|
|
12
|
+
* // Returns: [1, 2, 3, 4, [5, 6]]
|
|
13
|
+
*
|
|
14
|
+
* const arr = flatten([1, [2, 3], [4, [5, 6]]], 2);
|
|
15
|
+
* // Returns: [1, 2, 3, 4, 5, 6]
|
|
16
|
+
*/
|
|
17
|
+
declare function flattenDepth<T, D extends number = 1>(value: T[] | object, depth?: D): Array<FlatArray<T[], D>> | [];
|
|
18
|
+
|
|
19
|
+
export { flattenDepth };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flattens an array up to the specified depth.
|
|
3
|
+
*
|
|
4
|
+
* @template T - The type of elements within the array.
|
|
5
|
+
* @template D - The depth to which the array should be flattened.
|
|
6
|
+
* @param {T[] | object} value - The value to flatten.
|
|
7
|
+
* @param {D} depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.
|
|
8
|
+
* @returns {Array<FlatArray<T[], D>> | []} A new array that has been flattened.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const arr = flatten([1, [2, 3], [4, [5, 6]]], 1);
|
|
12
|
+
* // Returns: [1, 2, 3, 4, [5, 6]]
|
|
13
|
+
*
|
|
14
|
+
* const arr = flatten([1, [2, 3], [4, [5, 6]]], 2);
|
|
15
|
+
* // Returns: [1, 2, 3, 4, 5, 6]
|
|
16
|
+
*/
|
|
17
|
+
declare function flattenDepth<T, D extends number = 1>(value: T[] | object, depth?: D): Array<FlatArray<T[], D>> | [];
|
|
18
|
+
|
|
19
|
+
export { flattenDepth };
|
package/dist/compat/index.d.mts
CHANGED
|
@@ -7,7 +7,6 @@ export { dropRight } from '../array/dropRight.mjs';
|
|
|
7
7
|
export { dropRightWhile } from '../array/dropRightWhile.mjs';
|
|
8
8
|
export { dropWhile } from '../array/dropWhile.mjs';
|
|
9
9
|
export { flatMap } from '../array/flatMap.mjs';
|
|
10
|
-
export { flattenDeep } from '../array/flattenDeep.mjs';
|
|
11
10
|
export { forEachRight } from '../array/forEachRight.mjs';
|
|
12
11
|
export { groupBy } from '../array/groupBy.mjs';
|
|
13
12
|
export { intersection } from '../array/intersection.mjs';
|
|
@@ -99,6 +98,8 @@ export { concat } from './array/concat.mjs';
|
|
|
99
98
|
export { difference } from './array/difference.mjs';
|
|
100
99
|
export { fill } from './array/fill.mjs';
|
|
101
100
|
export { flatten } from './array/flatten.mjs';
|
|
101
|
+
export { flattenDeep } from './array/flattenDeep.mjs';
|
|
102
|
+
export { flattenDepth } from './array/flattenDepth.mjs';
|
|
102
103
|
export { zipObjectDeep } from './array/zipObjectDeep.mjs';
|
|
103
104
|
export { get } from './object/get.mjs';
|
|
104
105
|
export { set } from './object/set.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ export { dropRight } from '../array/dropRight.js';
|
|
|
7
7
|
export { dropRightWhile } from '../array/dropRightWhile.js';
|
|
8
8
|
export { dropWhile } from '../array/dropWhile.js';
|
|
9
9
|
export { flatMap } from '../array/flatMap.js';
|
|
10
|
-
export { flattenDeep } from '../array/flattenDeep.js';
|
|
11
10
|
export { forEachRight } from '../array/forEachRight.js';
|
|
12
11
|
export { groupBy } from '../array/groupBy.js';
|
|
13
12
|
export { intersection } from '../array/intersection.js';
|
|
@@ -99,6 +98,8 @@ export { concat } from './array/concat.js';
|
|
|
99
98
|
export { difference } from './array/difference.js';
|
|
100
99
|
export { fill } from './array/fill.js';
|
|
101
100
|
export { flatten } from './array/flatten.js';
|
|
101
|
+
export { flattenDeep } from './array/flattenDeep.js';
|
|
102
|
+
export { flattenDepth } from './array/flattenDepth.js';
|
|
102
103
|
export { zipObjectDeep } from './array/zipObjectDeep.js';
|
|
103
104
|
export { get } from './object/get.js';
|
|
104
105
|
export { set } from './object/set.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const size = require('../_chunk/size-CJyNw8.js');
|
|
6
6
|
const isNil = require('../_chunk/isNil-IuJ4cv.js');
|
|
7
7
|
const promise_index = require('../_chunk/index-CwRt_M.js');
|
|
8
8
|
const function_index = require('../function/index.js');
|
|
@@ -10,25 +10,25 @@ const math_index = require('../math/index.js');
|
|
|
10
10
|
const randomInt = require('../_chunk/randomInt-CF7bZK.js');
|
|
11
11
|
const object_index = require('../object/index.js');
|
|
12
12
|
const predicate_index = require('../predicate/index.js');
|
|
13
|
-
const
|
|
13
|
+
const isTypedArray$1 = require('../_chunk/isTypedArray-BBEkFl.js');
|
|
14
14
|
const string_index = require('../string/index.js');
|
|
15
15
|
|
|
16
|
-
function chunk(arr, size = 1) {
|
|
17
|
-
size = Math.max(Math.floor(size), 0);
|
|
18
|
-
if (size === 0) {
|
|
16
|
+
function chunk(arr, size$1 = 1) {
|
|
17
|
+
size$1 = Math.max(Math.floor(size$1), 0);
|
|
18
|
+
if (size$1 === 0) {
|
|
19
19
|
return [];
|
|
20
20
|
}
|
|
21
|
-
return
|
|
21
|
+
return size.chunk(arr, size$1);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
function concat(...values) {
|
|
25
|
-
return
|
|
25
|
+
return size.flatten(values);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
function difference(arr, ...values) {
|
|
29
29
|
const arr1 = arr;
|
|
30
|
-
const arr2 =
|
|
31
|
-
return
|
|
30
|
+
const arr2 = size.flatten(values);
|
|
31
|
+
return size.difference(arr1, arr2);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function fill(array, value, start = 0, end = array.length) {
|
|
@@ -40,7 +40,7 @@ function fill(array, value, start = 0, end = array.length) {
|
|
|
40
40
|
if (!end) {
|
|
41
41
|
end = 0;
|
|
42
42
|
}
|
|
43
|
-
return
|
|
43
|
+
return size.fill(array, value, start, end);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
function flatten(value, depth = 1) {
|
|
@@ -71,6 +71,14 @@ function flatten(value, depth = 1) {
|
|
|
71
71
|
return result;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
function flattenDeep(value) {
|
|
75
|
+
return flatten(value, Infinity);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function flattenDepth(value, depth = 1) {
|
|
79
|
+
return flatten(value, depth);
|
|
80
|
+
}
|
|
81
|
+
|
|
74
82
|
const IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
|
|
75
83
|
function isIndex(value) {
|
|
76
84
|
switch (typeof value) {
|
|
@@ -147,7 +155,7 @@ function set(obj, path, value) {
|
|
|
147
155
|
|
|
148
156
|
function zipObjectDeep(keys, values) {
|
|
149
157
|
const result = {};
|
|
150
|
-
const zipped =
|
|
158
|
+
const zipped = size.zip(keys, values);
|
|
151
159
|
for (let i = 0; i < zipped.length; i++) {
|
|
152
160
|
const [key, value] = zipped[i];
|
|
153
161
|
if (key != null) {
|
|
@@ -258,7 +266,7 @@ function isArray(value) {
|
|
|
258
266
|
}
|
|
259
267
|
|
|
260
268
|
function isTypedArray(x) {
|
|
261
|
-
return
|
|
269
|
+
return isTypedArray$1.isTypedArray(x);
|
|
262
270
|
}
|
|
263
271
|
|
|
264
272
|
function isArrayMatch(target, source) {
|
|
@@ -335,7 +343,7 @@ function isMatch(target, source) {
|
|
|
335
343
|
}
|
|
336
344
|
for (let i = 0; i < keys.length; i++) {
|
|
337
345
|
const key = keys[i];
|
|
338
|
-
if (!
|
|
346
|
+
if (!isTypedArray$1.isPrimitive(target) && !(key in target)) {
|
|
339
347
|
return false;
|
|
340
348
|
}
|
|
341
349
|
if (source[key] === undefined && target[key] !== undefined) {
|
|
@@ -398,53 +406,52 @@ function min(items = []) {
|
|
|
398
406
|
return minElement;
|
|
399
407
|
}
|
|
400
408
|
|
|
401
|
-
exports.compact =
|
|
402
|
-
exports.countBy =
|
|
403
|
-
exports.differenceBy =
|
|
404
|
-
exports.differenceWith =
|
|
405
|
-
exports.drop =
|
|
406
|
-
exports.dropRight =
|
|
407
|
-
exports.dropRightWhile =
|
|
408
|
-
exports.dropWhile =
|
|
409
|
-
exports.first =
|
|
410
|
-
exports.flatMap =
|
|
411
|
-
exports.
|
|
412
|
-
exports.
|
|
413
|
-
exports.
|
|
414
|
-
exports.
|
|
415
|
-
exports.
|
|
416
|
-
exports.
|
|
417
|
-
exports.
|
|
418
|
-
exports.
|
|
419
|
-
exports.
|
|
420
|
-
exports.
|
|
421
|
-
exports.
|
|
422
|
-
exports.
|
|
423
|
-
exports.
|
|
424
|
-
exports.
|
|
425
|
-
exports.
|
|
426
|
-
exports.
|
|
427
|
-
exports.
|
|
428
|
-
exports.
|
|
429
|
-
exports.
|
|
430
|
-
exports.
|
|
431
|
-
exports.
|
|
432
|
-
exports.
|
|
433
|
-
exports.
|
|
434
|
-
exports.
|
|
435
|
-
exports.
|
|
436
|
-
exports.
|
|
437
|
-
exports.
|
|
438
|
-
exports.
|
|
439
|
-
exports.
|
|
440
|
-
exports.
|
|
441
|
-
exports.
|
|
442
|
-
exports.
|
|
443
|
-
exports.
|
|
444
|
-
exports.
|
|
445
|
-
exports.
|
|
446
|
-
exports.
|
|
447
|
-
exports.zipWith = array_index.zipWith;
|
|
409
|
+
exports.compact = size.compact;
|
|
410
|
+
exports.countBy = size.countBy;
|
|
411
|
+
exports.differenceBy = size.differenceBy;
|
|
412
|
+
exports.differenceWith = size.differenceWith;
|
|
413
|
+
exports.drop = size.drop;
|
|
414
|
+
exports.dropRight = size.dropRight;
|
|
415
|
+
exports.dropRightWhile = size.dropRightWhile;
|
|
416
|
+
exports.dropWhile = size.dropWhile;
|
|
417
|
+
exports.first = size.head;
|
|
418
|
+
exports.flatMap = size.flatMap;
|
|
419
|
+
exports.forEachRight = size.forEachRight;
|
|
420
|
+
exports.groupBy = size.groupBy;
|
|
421
|
+
exports.head = size.head;
|
|
422
|
+
exports.initial = size.initial;
|
|
423
|
+
exports.intersection = size.intersection;
|
|
424
|
+
exports.intersectionBy = size.intersectionBy;
|
|
425
|
+
exports.intersectionWith = size.intersectionWith;
|
|
426
|
+
exports.keyBy = size.keyBy;
|
|
427
|
+
exports.last = size.last;
|
|
428
|
+
exports.maxBy = size.maxBy;
|
|
429
|
+
exports.minBy = size.minBy;
|
|
430
|
+
exports.orderBy = size.orderBy;
|
|
431
|
+
exports.partition = size.partition;
|
|
432
|
+
exports.sample = size.sample;
|
|
433
|
+
exports.sampleSize = size.sampleSize;
|
|
434
|
+
exports.shuffle = size.shuffle;
|
|
435
|
+
exports.size = size.size;
|
|
436
|
+
exports.tail = size.tail;
|
|
437
|
+
exports.take = size.take;
|
|
438
|
+
exports.takeRight = size.takeRight;
|
|
439
|
+
exports.takeRightWhile = size.takeRightWhile;
|
|
440
|
+
exports.takeWhile = size.takeWhile;
|
|
441
|
+
exports.toFilled = size.toFilled;
|
|
442
|
+
exports.unionBy = size.unionBy;
|
|
443
|
+
exports.unionWith = size.unionWith;
|
|
444
|
+
exports.uniqBy = size.uniqBy;
|
|
445
|
+
exports.uniqWith = size.uniqWith;
|
|
446
|
+
exports.unzip = size.unzip;
|
|
447
|
+
exports.unzipWith = size.unzipWith;
|
|
448
|
+
exports.without = size.without;
|
|
449
|
+
exports.xor = size.xor;
|
|
450
|
+
exports.xorBy = size.xorBy;
|
|
451
|
+
exports.xorWith = size.xorWith;
|
|
452
|
+
exports.zip = size.zip;
|
|
453
|
+
exports.zipObject = size.zipObject;
|
|
454
|
+
exports.zipWith = size.zipWith;
|
|
448
455
|
exports.isNil = isNil.isNil;
|
|
449
456
|
exports.union = isNil.union;
|
|
450
457
|
exports.uniq = isNil.uniq;
|
|
@@ -487,7 +494,7 @@ exports.isNotNil = predicate_index.isNotNil;
|
|
|
487
494
|
exports.isNull = predicate_index.isNull;
|
|
488
495
|
exports.isObjectLike = predicate_index.isObjectLike;
|
|
489
496
|
exports.isUndefined = predicate_index.isUndefined;
|
|
490
|
-
exports.isPrimitive =
|
|
497
|
+
exports.isPrimitive = isTypedArray$1.isPrimitive;
|
|
491
498
|
exports.camelCase = string_index.camelCase;
|
|
492
499
|
exports.capitalize = string_index.capitalize;
|
|
493
500
|
exports.kebabCase = string_index.kebabCase;
|
|
@@ -501,6 +508,8 @@ exports.difference = difference;
|
|
|
501
508
|
exports.endsWith = endsWith;
|
|
502
509
|
exports.fill = fill;
|
|
503
510
|
exports.flatten = flatten;
|
|
511
|
+
exports.flattenDeep = flattenDeep;
|
|
512
|
+
exports.flattenDepth = flattenDepth;
|
|
504
513
|
exports.get = get;
|
|
505
514
|
exports.isArray = isArray;
|
|
506
515
|
exports.isMatch = isMatch;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -7,7 +7,6 @@ export { dropRight } from '../array/dropRight.mjs';
|
|
|
7
7
|
export { dropRightWhile } from '../array/dropRightWhile.mjs';
|
|
8
8
|
export { dropWhile } from '../array/dropWhile.mjs';
|
|
9
9
|
export { flatMap } from '../array/flatMap.mjs';
|
|
10
|
-
export { flattenDeep } from '../array/flattenDeep.mjs';
|
|
11
10
|
export { forEachRight } from '../array/forEachRight.mjs';
|
|
12
11
|
export { groupBy } from '../array/groupBy.mjs';
|
|
13
12
|
export { intersection } from '../array/intersection.mjs';
|
|
@@ -99,6 +98,8 @@ export { concat } from './array/concat.mjs';
|
|
|
99
98
|
export { difference } from './array/difference.mjs';
|
|
100
99
|
export { fill } from './array/fill.mjs';
|
|
101
100
|
export { flatten } from './array/flatten.mjs';
|
|
101
|
+
export { flattenDeep } from './array/flattenDeep.mjs';
|
|
102
|
+
export { flattenDepth } from './array/flattenDepth.mjs';
|
|
102
103
|
export { zipObjectDeep } from './array/zipObjectDeep.mjs';
|
|
103
104
|
export { get } from './object/get.mjs';
|
|
104
105
|
export { set } from './object/set.mjs';
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
+
const size = require('./_chunk/size-CJyNw8.js');
|
|
5
6
|
const array_index = require('./array/index.js');
|
|
6
7
|
const isNil = require('./_chunk/isNil-IuJ4cv.js');
|
|
7
8
|
const promise_index = require('./_chunk/index-CwRt_M.js');
|
|
@@ -10,61 +11,61 @@ const math_index = require('./math/index.js');
|
|
|
10
11
|
const randomInt = require('./_chunk/randomInt-CF7bZK.js');
|
|
11
12
|
const object_index = require('./object/index.js');
|
|
12
13
|
const predicate_index = require('./predicate/index.js');
|
|
13
|
-
const
|
|
14
|
+
const isTypedArray = require('./_chunk/isTypedArray-BBEkFl.js');
|
|
14
15
|
const string_index = require('./string/index.js');
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
|
|
18
|
-
exports.chunk =
|
|
19
|
-
exports.compact =
|
|
20
|
-
exports.countBy =
|
|
21
|
-
exports.difference =
|
|
22
|
-
exports.differenceBy =
|
|
23
|
-
exports.differenceWith =
|
|
24
|
-
exports.drop =
|
|
25
|
-
exports.dropRight =
|
|
26
|
-
exports.dropRightWhile =
|
|
27
|
-
exports.dropWhile =
|
|
28
|
-
exports.fill =
|
|
29
|
-
exports.flatMap =
|
|
30
|
-
exports.flatten =
|
|
19
|
+
exports.chunk = size.chunk;
|
|
20
|
+
exports.compact = size.compact;
|
|
21
|
+
exports.countBy = size.countBy;
|
|
22
|
+
exports.difference = size.difference;
|
|
23
|
+
exports.differenceBy = size.differenceBy;
|
|
24
|
+
exports.differenceWith = size.differenceWith;
|
|
25
|
+
exports.drop = size.drop;
|
|
26
|
+
exports.dropRight = size.dropRight;
|
|
27
|
+
exports.dropRightWhile = size.dropRightWhile;
|
|
28
|
+
exports.dropWhile = size.dropWhile;
|
|
29
|
+
exports.fill = size.fill;
|
|
30
|
+
exports.flatMap = size.flatMap;
|
|
31
|
+
exports.flatten = size.flatten;
|
|
32
|
+
exports.forEachRight = size.forEachRight;
|
|
33
|
+
exports.groupBy = size.groupBy;
|
|
34
|
+
exports.head = size.head;
|
|
35
|
+
exports.initial = size.initial;
|
|
36
|
+
exports.intersection = size.intersection;
|
|
37
|
+
exports.intersectionBy = size.intersectionBy;
|
|
38
|
+
exports.intersectionWith = size.intersectionWith;
|
|
39
|
+
exports.keyBy = size.keyBy;
|
|
40
|
+
exports.last = size.last;
|
|
41
|
+
exports.maxBy = size.maxBy;
|
|
42
|
+
exports.minBy = size.minBy;
|
|
43
|
+
exports.orderBy = size.orderBy;
|
|
44
|
+
exports.partition = size.partition;
|
|
45
|
+
exports.sample = size.sample;
|
|
46
|
+
exports.sampleSize = size.sampleSize;
|
|
47
|
+
exports.shuffle = size.shuffle;
|
|
48
|
+
exports.size = size.size;
|
|
49
|
+
exports.tail = size.tail;
|
|
50
|
+
exports.take = size.take;
|
|
51
|
+
exports.takeRight = size.takeRight;
|
|
52
|
+
exports.takeRightWhile = size.takeRightWhile;
|
|
53
|
+
exports.takeWhile = size.takeWhile;
|
|
54
|
+
exports.toFilled = size.toFilled;
|
|
55
|
+
exports.unionBy = size.unionBy;
|
|
56
|
+
exports.unionWith = size.unionWith;
|
|
57
|
+
exports.uniqBy = size.uniqBy;
|
|
58
|
+
exports.uniqWith = size.uniqWith;
|
|
59
|
+
exports.unzip = size.unzip;
|
|
60
|
+
exports.unzipWith = size.unzipWith;
|
|
61
|
+
exports.without = size.without;
|
|
62
|
+
exports.xor = size.xor;
|
|
63
|
+
exports.xorBy = size.xorBy;
|
|
64
|
+
exports.xorWith = size.xorWith;
|
|
65
|
+
exports.zip = size.zip;
|
|
66
|
+
exports.zipObject = size.zipObject;
|
|
67
|
+
exports.zipWith = size.zipWith;
|
|
31
68
|
exports.flattenDeep = array_index.flattenDeep;
|
|
32
|
-
exports.forEachRight = array_index.forEachRight;
|
|
33
|
-
exports.groupBy = array_index.groupBy;
|
|
34
|
-
exports.head = array_index.head;
|
|
35
|
-
exports.initial = array_index.initial;
|
|
36
|
-
exports.intersection = array_index.intersection;
|
|
37
|
-
exports.intersectionBy = array_index.intersectionBy;
|
|
38
|
-
exports.intersectionWith = array_index.intersectionWith;
|
|
39
|
-
exports.keyBy = array_index.keyBy;
|
|
40
|
-
exports.last = array_index.last;
|
|
41
|
-
exports.maxBy = array_index.maxBy;
|
|
42
|
-
exports.minBy = array_index.minBy;
|
|
43
|
-
exports.orderBy = array_index.orderBy;
|
|
44
|
-
exports.partition = array_index.partition;
|
|
45
|
-
exports.sample = array_index.sample;
|
|
46
|
-
exports.sampleSize = array_index.sampleSize;
|
|
47
|
-
exports.shuffle = array_index.shuffle;
|
|
48
|
-
exports.size = array_index.size;
|
|
49
|
-
exports.tail = array_index.tail;
|
|
50
|
-
exports.take = array_index.take;
|
|
51
|
-
exports.takeRight = array_index.takeRight;
|
|
52
|
-
exports.takeRightWhile = array_index.takeRightWhile;
|
|
53
|
-
exports.takeWhile = array_index.takeWhile;
|
|
54
|
-
exports.toFilled = array_index.toFilled;
|
|
55
|
-
exports.unionBy = array_index.unionBy;
|
|
56
|
-
exports.unionWith = array_index.unionWith;
|
|
57
|
-
exports.uniqBy = array_index.uniqBy;
|
|
58
|
-
exports.uniqWith = array_index.uniqWith;
|
|
59
|
-
exports.unzip = array_index.unzip;
|
|
60
|
-
exports.unzipWith = array_index.unzipWith;
|
|
61
|
-
exports.without = array_index.without;
|
|
62
|
-
exports.xor = array_index.xor;
|
|
63
|
-
exports.xorBy = array_index.xorBy;
|
|
64
|
-
exports.xorWith = array_index.xorWith;
|
|
65
|
-
exports.zip = array_index.zip;
|
|
66
|
-
exports.zipObject = array_index.zipObject;
|
|
67
|
-
exports.zipWith = array_index.zipWith;
|
|
68
69
|
exports.isNil = isNil.isNil;
|
|
69
70
|
exports.union = isNil.union;
|
|
70
71
|
exports.uniq = isNil.uniq;
|
|
@@ -108,9 +109,9 @@ exports.isNotNil = predicate_index.isNotNil;
|
|
|
108
109
|
exports.isNull = predicate_index.isNull;
|
|
109
110
|
exports.isObjectLike = predicate_index.isObjectLike;
|
|
110
111
|
exports.isUndefined = predicate_index.isUndefined;
|
|
111
|
-
exports.isPlainObject =
|
|
112
|
-
exports.isPrimitive =
|
|
113
|
-
exports.isTypedArray =
|
|
112
|
+
exports.isPlainObject = isTypedArray.isPlainObject;
|
|
113
|
+
exports.isPrimitive = isTypedArray.isPrimitive;
|
|
114
|
+
exports.isTypedArray = isTypedArray.isTypedArray;
|
|
114
115
|
exports.camelCase = string_index.camelCase;
|
|
115
116
|
exports.capitalize = string_index.capitalize;
|
|
116
117
|
exports.kebabCase = string_index.kebabCase;
|
|
@@ -17,10 +17,10 @@ function cloneDeepImpl(obj, stack = new Map()) {
|
|
|
17
17
|
for (let i = 0; i < obj.length; i++) {
|
|
18
18
|
result[i] = cloneDeepImpl(obj[i], stack);
|
|
19
19
|
}
|
|
20
|
-
if (
|
|
20
|
+
if (Object.prototype.hasOwnProperty.call(obj, 'index')) {
|
|
21
21
|
result.index = obj.index;
|
|
22
22
|
}
|
|
23
|
-
if (
|
|
23
|
+
if (Object.prototype.hasOwnProperty.call(obj, 'input')) {
|
|
24
24
|
result.input = obj.input;
|
|
25
25
|
}
|
|
26
26
|
return result;
|
package/dist/object/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const isTypedArray = require('../_chunk/isTypedArray-BBEkFl.js');
|
|
6
6
|
|
|
7
7
|
function omit(obj, keys) {
|
|
8
8
|
const result = { ...obj };
|
|
@@ -101,7 +101,7 @@ function flattenObjectImpl(object, prefix = '') {
|
|
|
101
101
|
const key = keys[i];
|
|
102
102
|
const value = object[key];
|
|
103
103
|
const prefixedKey = prefix ? `${prefix}.${key}` : key;
|
|
104
|
-
if (
|
|
104
|
+
if (isTypedArray.isPlainObject(value) && Object.keys(value).length > 0) {
|
|
105
105
|
Object.assign(result, flattenObjectImpl(value, prefixedKey));
|
|
106
106
|
continue;
|
|
107
107
|
}
|
|
@@ -142,7 +142,7 @@ function cloneDeep(obj) {
|
|
|
142
142
|
return cloneDeepImpl(obj);
|
|
143
143
|
}
|
|
144
144
|
function cloneDeepImpl(obj, stack = new Map()) {
|
|
145
|
-
if (
|
|
145
|
+
if (isTypedArray.isPrimitive(obj)) {
|
|
146
146
|
return obj;
|
|
147
147
|
}
|
|
148
148
|
if (stack.has(obj)) {
|
|
@@ -154,10 +154,10 @@ function cloneDeepImpl(obj, stack = new Map()) {
|
|
|
154
154
|
for (let i = 0; i < obj.length; i++) {
|
|
155
155
|
result[i] = cloneDeepImpl(obj[i], stack);
|
|
156
156
|
}
|
|
157
|
-
if (
|
|
157
|
+
if (Object.prototype.hasOwnProperty.call(obj, 'index')) {
|
|
158
158
|
result.index = obj.index;
|
|
159
159
|
}
|
|
160
|
-
if (
|
|
160
|
+
if (Object.prototype.hasOwnProperty.call(obj, 'input')) {
|
|
161
161
|
result.input = obj.input;
|
|
162
162
|
}
|
|
163
163
|
return result;
|
|
@@ -189,7 +189,7 @@ function cloneDeepImpl(obj, stack = new Map()) {
|
|
|
189
189
|
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(obj)) {
|
|
190
190
|
return obj.subarray();
|
|
191
191
|
}
|
|
192
|
-
if (
|
|
192
|
+
if (isTypedArray.isTypedArray(obj)) {
|
|
193
193
|
const result = new (Object.getPrototypeOf(obj).constructor)(obj.length);
|
|
194
194
|
stack.set(obj, result);
|
|
195
195
|
for (let i = 0; i < obj.length; i++) {
|
package/dist/predicate/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const isNil = require('../_chunk/isNil-IuJ4cv.js');
|
|
6
|
-
const
|
|
6
|
+
const isTypedArray = require('../_chunk/isTypedArray-BBEkFl.js');
|
|
7
7
|
|
|
8
8
|
function isEqual(a, b) {
|
|
9
9
|
if (Object.is(a, b)) {
|
|
@@ -78,9 +78,9 @@ function isArguments(value) {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
exports.isNil = isNil.isNil;
|
|
81
|
-
exports.isPlainObject =
|
|
82
|
-
exports.isPrimitive =
|
|
83
|
-
exports.isTypedArray =
|
|
81
|
+
exports.isPlainObject = isTypedArray.isPlainObject;
|
|
82
|
+
exports.isPrimitive = isTypedArray.isPrimitive;
|
|
83
|
+
exports.isTypedArray = isTypedArray.isTypedArray;
|
|
84
84
|
exports.isArguments = isArguments;
|
|
85
85
|
exports.isArrayLike = isArrayLike;
|
|
86
86
|
exports.isEqual = isEqual;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
3
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
4
|
-
"version": "1.13.1-dev.
|
|
4
|
+
"version": "1.13.1-dev.366+6f559c5b",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|
|
@@ -20,6 +20,10 @@ function isPlainObject(object) {
|
|
|
20
20
|
return Object.getPrototypeOf(object) === proto;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
function isPrimitive(value) {
|
|
24
|
+
return value == null || (typeof value !== 'object' && typeof value !== 'function');
|
|
25
|
+
}
|
|
26
|
+
|
|
23
27
|
function isTypedArray(x) {
|
|
24
28
|
return (x instanceof Uint8Array ||
|
|
25
29
|
x instanceof Uint8ClampedArray ||
|
|
@@ -34,10 +38,6 @@ function isTypedArray(x) {
|
|
|
34
38
|
x instanceof Float64Array);
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
function isPrimitive(value) {
|
|
38
|
-
return value == null || (typeof value !== 'object' && typeof value !== 'function');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
41
|
exports.isPlainObject = isPlainObject;
|
|
42
42
|
exports.isPrimitive = isPrimitive;
|
|
43
43
|
exports.isTypedArray = isTypedArray;
|