es-toolkit 1.17.0 → 1.18.0-dev.573
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/README.md +1 -1
- package/dist/_chunk/{index-CoqN5B.js → index-BGZDR9.js} +4 -1
- package/dist/_chunk/{isTypedArray-BBEkFl.js → isTypedArray-Dsrnb1.js} +1 -11
- package/dist/_chunk/{isFunction-aCEz9d.js → isWeakSet-BerD1A.js} +12 -2
- package/dist/_chunk/rest-CXt9w3.js +182 -0
- package/dist/_chunk/{toMerged-BGwYW5.js → toMerged-DN1PPP.js} +1 -1
- package/dist/_chunk/{initial-Ci2bn_.js → zipWith-CYaH1Y.js} +46 -70
- package/dist/array/countBy.d.mts +10 -0
- package/dist/array/countBy.d.ts +10 -0
- package/dist/array/fill.d.mts +55 -2
- package/dist/array/fill.d.ts +55 -2
- package/dist/array/flatMapDeep.d.mts +18 -0
- package/dist/array/flatMapDeep.d.ts +18 -0
- package/dist/array/flatMapDeep.mjs +7 -0
- package/dist/array/flattenDeep.d.mts +1 -1
- package/dist/array/flattenDeep.d.ts +1 -1
- package/dist/array/head.d.mts +14 -3
- package/dist/array/head.d.ts +14 -3
- package/dist/array/index.d.mts +9 -8
- package/dist/array/index.d.ts +9 -8
- package/dist/array/index.js +87 -58
- package/dist/array/index.mjs +9 -8
- package/dist/array/last.d.mts +23 -1
- package/dist/array/last.d.ts +23 -1
- package/dist/array/maxBy.d.mts +13 -1
- package/dist/array/maxBy.d.ts +13 -1
- package/dist/array/minBy.d.mts +13 -1
- package/dist/array/minBy.d.ts +13 -1
- package/dist/array/toFilled.d.mts +59 -2
- package/dist/array/toFilled.d.ts +59 -2
- package/dist/array/zip.d.mts +65 -7
- package/dist/array/zip.d.ts +65 -7
- package/dist/array/zipObject.d.mts +2 -4
- package/dist/array/zipObject.d.ts +2 -4
- package/dist/array/zipWith.d.mts +39 -6
- package/dist/array/zipWith.d.ts +39 -6
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/_internal/compareValues.mjs +30 -5
- package/dist/compat/_internal/normalizeForCase.mjs +9 -0
- package/dist/compat/array/castArray.d.mts +29 -0
- package/dist/compat/array/castArray.d.ts +29 -0
- package/dist/compat/array/castArray.mjs +8 -0
- package/dist/compat/array/difference.d.mts +19 -0
- package/dist/compat/array/difference.d.ts +19 -0
- package/dist/compat/array/fill.d.mts +55 -2
- package/dist/compat/array/fill.d.ts +55 -2
- package/dist/compat/array/findLastIndex.d.mts +66 -0
- package/dist/compat/array/findLastIndex.d.ts +66 -0
- package/dist/compat/array/findLastIndex.mjs +33 -0
- package/dist/compat/array/join.d.mts +16 -0
- package/dist/compat/array/join.d.ts +16 -0
- package/dist/compat/array/join.mjs +5 -0
- package/dist/compat/array/orderBy.d.mts +6 -6
- package/dist/compat/array/orderBy.d.ts +6 -6
- package/dist/compat/array/orderBy.mjs +26 -18
- package/dist/compat/array/some.d.mts +86 -0
- package/dist/compat/array/some.d.ts +86 -0
- package/dist/compat/array/some.mjs +36 -0
- package/dist/compat/array/sortBy.d.mts +34 -0
- package/dist/compat/array/sortBy.d.ts +34 -0
- package/dist/compat/array/sortBy.mjs +7 -0
- package/dist/compat/function/ary.d.mts +11 -1
- package/dist/compat/function/ary.d.ts +11 -1
- package/dist/compat/function/attempt.d.mts +33 -0
- package/dist/compat/function/attempt.d.ts +33 -0
- package/dist/compat/function/attempt.mjs +10 -0
- package/dist/compat/function/bindKey.d.mts +45 -0
- package/dist/compat/function/bindKey.d.ts +45 -0
- package/dist/compat/function/bindKey.mjs +27 -0
- package/dist/compat/function/rearg.d.mts +18 -0
- package/dist/compat/function/rearg.d.ts +18 -0
- package/dist/compat/function/rearg.mjs +14 -0
- package/dist/compat/function/spread.d.mts +47 -0
- package/dist/compat/function/spread.d.ts +47 -0
- package/dist/compat/function/spread.mjs +16 -0
- package/dist/compat/index.d.mts +31 -10
- package/dist/compat/index.d.ts +31 -10
- package/dist/compat/index.js +401 -143
- package/dist/compat/index.mjs +32 -11
- package/dist/compat/math/max.d.mts +16 -5
- package/dist/compat/math/max.d.ts +16 -5
- package/dist/compat/math/min.d.mts +16 -4
- package/dist/compat/math/min.d.ts +16 -4
- package/dist/compat/math/parseInt.d.mts +20 -0
- package/dist/compat/math/parseInt.d.ts +20 -0
- package/dist/compat/math/parseInt.mjs +8 -0
- package/dist/compat/object/fromPairs.d.mts +29 -0
- package/dist/compat/object/fromPairs.d.ts +29 -0
- package/dist/compat/object/fromPairs.mjs +14 -0
- package/dist/compat/predicate/conforms.d.mts +22 -0
- package/dist/compat/predicate/conforms.d.ts +22 -0
- package/dist/compat/predicate/conforms.mjs +11 -0
- package/dist/compat/predicate/conformsTo.d.mts +29 -0
- package/dist/compat/predicate/conformsTo.d.ts +29 -0
- package/dist/compat/predicate/conformsTo.mjs +18 -0
- package/dist/compat/predicate/isObject.d.mts +26 -0
- package/dist/compat/predicate/isObject.d.ts +26 -0
- package/dist/compat/predicate/isObject.mjs +5 -0
- package/dist/compat/predicate/isRegExp.d.mts +7 -0
- package/dist/compat/predicate/isRegExp.d.ts +7 -0
- package/dist/compat/predicate/isTypedArray.d.mts +10 -0
- package/dist/compat/predicate/isTypedArray.d.ts +10 -0
- package/dist/compat/predicate/isWeakMap.d.mts +23 -0
- package/dist/compat/predicate/isWeakMap.d.ts +23 -0
- package/dist/compat/predicate/isWeakMap.mjs +7 -0
- package/dist/compat/predicate/isWeakSet.d.mts +23 -0
- package/dist/compat/predicate/isWeakSet.d.ts +23 -0
- package/dist/compat/predicate/isWeakSet.mjs +7 -0
- package/dist/compat/string/camelCase.d.mts +18 -0
- package/dist/compat/string/camelCase.d.ts +18 -0
- package/dist/compat/string/camelCase.mjs +8 -0
- package/dist/compat/string/endsWith.d.mts +1 -1
- package/dist/compat/string/endsWith.d.ts +1 -1
- package/dist/compat/string/endsWith.mjs +2 -2
- package/dist/compat/string/repeat.d.mts +17 -0
- package/dist/compat/string/repeat.d.ts +17 -0
- package/dist/compat/string/repeat.mjs +5 -0
- package/dist/compat/string/startsWith.d.mts +1 -1
- package/dist/compat/string/startsWith.d.ts +1 -1
- package/dist/compat/string/startsWith.mjs +2 -2
- package/dist/function/after.d.mts +1 -1
- package/dist/function/after.d.ts +1 -1
- package/dist/function/after.mjs +2 -2
- package/dist/function/before.d.mts +1 -1
- package/dist/function/before.d.ts +1 -1
- package/dist/function/before.mjs +2 -2
- package/dist/function/debounce.d.mts +3 -3
- package/dist/function/debounce.d.ts +3 -3
- package/dist/function/index.d.mts +1 -0
- package/dist/function/index.d.ts +1 -0
- package/dist/function/index.js +22 -180
- package/dist/function/index.mjs +1 -0
- package/dist/function/memoize.d.mts +37 -1
- package/dist/function/memoize.d.ts +37 -1
- package/dist/function/negate.d.mts +7 -1
- package/dist/function/negate.d.ts +7 -1
- package/dist/function/spread.d.mts +19 -0
- package/dist/function/spread.d.ts +19 -0
- package/dist/function/spread.mjs +7 -0
- package/dist/function/unary.d.mts +7 -0
- package/dist/function/unary.d.ts +7 -0
- package/dist/index.d.mts +16 -8
- package/dist/index.d.ts +16 -8
- package/dist/index.js +89 -80
- package/dist/index.mjs +16 -8
- package/dist/math/clamp.d.mts +14 -3
- package/dist/math/clamp.d.ts +14 -3
- package/dist/math/random.d.mts +13 -2
- package/dist/math/random.d.ts +13 -2
- package/dist/math/randomInt.d.mts +11 -3
- package/dist/math/randomInt.d.ts +11 -3
- package/dist/math/range.d.mts +25 -0
- package/dist/math/range.d.ts +25 -0
- package/dist/object/index.js +1 -1
- package/dist/object/invert.d.mts +2 -4
- package/dist/object/invert.d.ts +2 -4
- package/dist/predicate/index.d.mts +2 -0
- package/dist/predicate/index.d.ts +2 -0
- package/dist/predicate/index.js +11 -9
- package/dist/predicate/index.mjs +2 -0
- package/dist/predicate/isNotNil.mjs +1 -1
- package/dist/predicate/isPrimitive.d.mts +14 -0
- package/dist/predicate/isPrimitive.d.ts +14 -0
- package/dist/predicate/isRegExp.d.mts +8 -1
- package/dist/predicate/isRegExp.d.ts +8 -1
- package/dist/predicate/isSymbol.d.mts +15 -0
- package/dist/predicate/isSymbol.d.ts +15 -0
- package/dist/predicate/isTypedArray.d.mts +10 -0
- package/dist/predicate/isTypedArray.d.ts +10 -0
- package/dist/predicate/isTypedArray.mjs +1 -11
- package/dist/predicate/isWeakMap.d.mts +23 -0
- package/dist/predicate/isWeakMap.d.ts +23 -0
- package/dist/predicate/isWeakMap.mjs +5 -0
- package/dist/predicate/isWeakSet.d.mts +23 -0
- package/dist/predicate/isWeakSet.d.ts +23 -0
- package/dist/predicate/isWeakSet.mjs +5 -0
- package/dist/promise/delay.mjs +4 -1
- package/dist/promise/index.js +1 -1
- package/dist/promise/timeout.d.mts +7 -0
- package/dist/promise/timeout.d.ts +7 -0
- package/dist/string/capitalize.d.mts +1 -1
- package/dist/string/capitalize.d.ts +1 -1
- package/dist/string/capitalize.mjs +2 -2
- package/dist/string/deburr.mjs +5 -5
- package/dist/string/escape.d.mts +16 -0
- package/dist/string/escape.d.ts +16 -0
- package/dist/string/escape.mjs +12 -0
- package/dist/string/escapeRegExp.d.mts +14 -0
- package/dist/string/escapeRegExp.d.ts +14 -0
- package/dist/string/escapeRegExp.mjs +5 -0
- package/dist/string/index.d.mts +4 -0
- package/dist/string/index.d.ts +4 -0
- package/dist/string/index.js +53 -19
- package/dist/string/index.mjs +4 -0
- package/dist/string/kebabCase.d.mts +1 -1
- package/dist/string/kebabCase.d.ts +1 -1
- package/dist/string/kebabCase.mjs +2 -2
- package/dist/string/lowerCase.d.mts +1 -1
- package/dist/string/lowerCase.d.ts +1 -1
- package/dist/string/lowerCase.mjs +2 -2
- package/dist/string/lowerFirst.d.mts +1 -1
- package/dist/string/lowerFirst.d.ts +1 -1
- package/dist/string/lowerFirst.mjs +2 -2
- package/dist/string/pad.d.mts +19 -0
- package/dist/string/pad.d.ts +19 -0
- package/dist/string/pad.mjs +5 -0
- package/dist/string/pascalCase.d.mts +1 -1
- package/dist/string/pascalCase.d.ts +1 -1
- package/dist/string/pascalCase.mjs +2 -2
- package/dist/string/snakeCase.d.mts +1 -1
- package/dist/string/snakeCase.d.ts +1 -1
- package/dist/string/snakeCase.mjs +2 -2
- package/dist/string/unescape.d.mts +16 -0
- package/dist/string/unescape.d.ts +16 -0
- package/dist/string/unescape.mjs +12 -0
- package/dist/string/upperFirst.d.mts +1 -1
- package/dist/string/upperFirst.d.ts +1 -1
- package/dist/string/upperFirst.mjs +2 -2
- package/package.json +7 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ExtractNestedArrayType } from './flattenDeep.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Recursively maps each element in an array using a provided iteratee function and then deeply flattens the resulting array.
|
|
5
|
+
*
|
|
6
|
+
* @template T - The type of elements within the array.
|
|
7
|
+
* @template U - The type of elements within the returned array from the iteratee function.
|
|
8
|
+
* @param {T[]} arr - The array to flatten.
|
|
9
|
+
* @param {(item: T) => U} iteratee - The function that produces the new array elements.
|
|
10
|
+
* @returns {Array<ExtractNestedArrayType<U>>} A new array that has been flattened.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const result = flatMapDeep([1, 2, 3], n => [[n, n]]);
|
|
14
|
+
* // [1, 1, 2, 2, 3, 3]
|
|
15
|
+
*/
|
|
16
|
+
declare function flatMapDeep<T, U>(arr: readonly T[], iteratee: (item: T) => U): Array<ExtractNestedArrayType<U>>;
|
|
17
|
+
|
|
18
|
+
export { flatMapDeep };
|
package/dist/array/head.d.mts
CHANGED
|
@@ -5,19 +5,30 @@
|
|
|
5
5
|
* If the array is empty, the function returns `undefined`.
|
|
6
6
|
*
|
|
7
7
|
* @template T - The type of elements in the array.
|
|
8
|
-
* @param {T[]} arr -
|
|
9
|
-
* @returns {T
|
|
8
|
+
* @param {[T, ...T[]]} arr - A non-empty array from which to get the first element.
|
|
9
|
+
* @returns {T} The first element of the array.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* const arr = [1, 2, 3];
|
|
13
13
|
* const firstElement = head(arr);
|
|
14
14
|
* // firstElement will be 1
|
|
15
|
+
*/
|
|
16
|
+
declare function head<T>(arr: readonly [T, ...T[]]): T;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the first element of an array or `undefined` if the array is empty.
|
|
19
|
+
*
|
|
20
|
+
* This function takes an array and returns the first element of the array.
|
|
21
|
+
* If the array is empty, the function returns `undefined`.
|
|
15
22
|
*
|
|
23
|
+
* @template T - The type of elements in the array.
|
|
24
|
+
* @param {T[]} arr - The array from which to get the first element.
|
|
25
|
+
* @returns {T | undefined} The first element of the array, or `undefined` if the array is empty.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
16
28
|
* const emptyArr: number[] = [];
|
|
17
29
|
* const noElement = head(emptyArr);
|
|
18
30
|
* // noElement will be undefined
|
|
19
31
|
*/
|
|
20
|
-
declare function head<T>(arr: readonly [T, ...T[]]): T;
|
|
21
32
|
declare function head<T>(arr: readonly T[]): T | undefined;
|
|
22
33
|
|
|
23
34
|
export { head };
|
package/dist/array/head.d.ts
CHANGED
|
@@ -5,19 +5,30 @@
|
|
|
5
5
|
* If the array is empty, the function returns `undefined`.
|
|
6
6
|
*
|
|
7
7
|
* @template T - The type of elements in the array.
|
|
8
|
-
* @param {T[]} arr -
|
|
9
|
-
* @returns {T
|
|
8
|
+
* @param {[T, ...T[]]} arr - A non-empty array from which to get the first element.
|
|
9
|
+
* @returns {T} The first element of the array.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* const arr = [1, 2, 3];
|
|
13
13
|
* const firstElement = head(arr);
|
|
14
14
|
* // firstElement will be 1
|
|
15
|
+
*/
|
|
16
|
+
declare function head<T>(arr: readonly [T, ...T[]]): T;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the first element of an array or `undefined` if the array is empty.
|
|
19
|
+
*
|
|
20
|
+
* This function takes an array and returns the first element of the array.
|
|
21
|
+
* If the array is empty, the function returns `undefined`.
|
|
15
22
|
*
|
|
23
|
+
* @template T - The type of elements in the array.
|
|
24
|
+
* @param {T[]} arr - The array from which to get the first element.
|
|
25
|
+
* @returns {T | undefined} The first element of the array, or `undefined` if the array is empty.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
16
28
|
* const emptyArr: number[] = [];
|
|
17
29
|
* const noElement = head(emptyArr);
|
|
18
30
|
* // noElement will be undefined
|
|
19
31
|
*/
|
|
20
|
-
declare function head<T>(arr: readonly [T, ...T[]]): T;
|
|
21
32
|
declare function head<T>(arr: readonly T[]): T | undefined;
|
|
22
33
|
|
|
23
34
|
export { head };
|
package/dist/array/index.d.mts
CHANGED
|
@@ -11,27 +11,34 @@ export { dropRightWhile } from './dropRightWhile.mjs';
|
|
|
11
11
|
export { dropWhile } from './dropWhile.mjs';
|
|
12
12
|
export { fill } from './fill.mjs';
|
|
13
13
|
export { flatMap } from './flatMap.mjs';
|
|
14
|
+
export { flatMapDeep } from './flatMapDeep.mjs';
|
|
14
15
|
export { flatten } from './flatten.mjs';
|
|
15
16
|
export { flattenDeep } from './flattenDeep.mjs';
|
|
16
17
|
export { forEachRight } from './forEachRight.mjs';
|
|
17
18
|
export { groupBy } from './groupBy.mjs';
|
|
19
|
+
export { head } from './head.mjs';
|
|
20
|
+
export { initial } from './initial.mjs';
|
|
18
21
|
export { intersection } from './intersection.mjs';
|
|
19
22
|
export { intersectionBy } from './intersectionBy.mjs';
|
|
20
23
|
export { intersectionWith } from './intersectionWith.mjs';
|
|
24
|
+
export { isSubset } from './isSubset.mjs';
|
|
21
25
|
export { keyBy } from './keyBy.mjs';
|
|
26
|
+
export { last } from './last.mjs';
|
|
22
27
|
export { maxBy } from './maxBy.mjs';
|
|
23
28
|
export { minBy } from './minBy.mjs';
|
|
24
29
|
export { orderBy } from './orderBy.mjs';
|
|
25
30
|
export { partition } from './partition.mjs';
|
|
26
31
|
export { pullAt } from './pullAt.mjs';
|
|
27
|
-
export { sortBy } from './sortBy.mjs';
|
|
28
32
|
export { sample } from './sample.mjs';
|
|
29
33
|
export { sampleSize } from './sampleSize.mjs';
|
|
30
34
|
export { shuffle } from './shuffle.mjs';
|
|
35
|
+
export { sortBy } from './sortBy.mjs';
|
|
36
|
+
export { tail } from './tail.mjs';
|
|
31
37
|
export { take } from './take.mjs';
|
|
32
38
|
export { takeRight } from './takeRight.mjs';
|
|
33
39
|
export { takeRightWhile } from './takeRightWhile.mjs';
|
|
34
40
|
export { takeWhile } from './takeWhile.mjs';
|
|
41
|
+
export { toFilled } from './toFilled.mjs';
|
|
35
42
|
export { union } from './union.mjs';
|
|
36
43
|
export { unionBy } from './unionBy.mjs';
|
|
37
44
|
export { unionWith } from './unionWith.mjs';
|
|
@@ -40,16 +47,10 @@ export { uniqBy } from './uniqBy.mjs';
|
|
|
40
47
|
export { uniqWith } from './uniqWith.mjs';
|
|
41
48
|
export { unzip } from './unzip.mjs';
|
|
42
49
|
export { unzipWith } from './unzipWith.mjs';
|
|
50
|
+
export { without } from './without.mjs';
|
|
43
51
|
export { xor } from './xor.mjs';
|
|
44
52
|
export { xorBy } from './xorBy.mjs';
|
|
45
53
|
export { xorWith } from './xorWith.mjs';
|
|
46
54
|
export { zip } from './zip.mjs';
|
|
47
55
|
export { zipObject } from './zipObject.mjs';
|
|
48
56
|
export { zipWith } from './zipWith.mjs';
|
|
49
|
-
export { without } from './without.mjs';
|
|
50
|
-
export { head } from './head.mjs';
|
|
51
|
-
export { isSubset } from './isSubset.mjs';
|
|
52
|
-
export { tail } from './tail.mjs';
|
|
53
|
-
export { toFilled } from './toFilled.mjs';
|
|
54
|
-
export { last } from './last.mjs';
|
|
55
|
-
export { initial } from './initial.mjs';
|
package/dist/array/index.d.ts
CHANGED
|
@@ -11,27 +11,34 @@ export { dropRightWhile } from './dropRightWhile.js';
|
|
|
11
11
|
export { dropWhile } from './dropWhile.js';
|
|
12
12
|
export { fill } from './fill.js';
|
|
13
13
|
export { flatMap } from './flatMap.js';
|
|
14
|
+
export { flatMapDeep } from './flatMapDeep.js';
|
|
14
15
|
export { flatten } from './flatten.js';
|
|
15
16
|
export { flattenDeep } from './flattenDeep.js';
|
|
16
17
|
export { forEachRight } from './forEachRight.js';
|
|
17
18
|
export { groupBy } from './groupBy.js';
|
|
19
|
+
export { head } from './head.js';
|
|
20
|
+
export { initial } from './initial.js';
|
|
18
21
|
export { intersection } from './intersection.js';
|
|
19
22
|
export { intersectionBy } from './intersectionBy.js';
|
|
20
23
|
export { intersectionWith } from './intersectionWith.js';
|
|
24
|
+
export { isSubset } from './isSubset.js';
|
|
21
25
|
export { keyBy } from './keyBy.js';
|
|
26
|
+
export { last } from './last.js';
|
|
22
27
|
export { maxBy } from './maxBy.js';
|
|
23
28
|
export { minBy } from './minBy.js';
|
|
24
29
|
export { orderBy } from './orderBy.js';
|
|
25
30
|
export { partition } from './partition.js';
|
|
26
31
|
export { pullAt } from './pullAt.js';
|
|
27
|
-
export { sortBy } from './sortBy.js';
|
|
28
32
|
export { sample } from './sample.js';
|
|
29
33
|
export { sampleSize } from './sampleSize.js';
|
|
30
34
|
export { shuffle } from './shuffle.js';
|
|
35
|
+
export { sortBy } from './sortBy.js';
|
|
36
|
+
export { tail } from './tail.js';
|
|
31
37
|
export { take } from './take.js';
|
|
32
38
|
export { takeRight } from './takeRight.js';
|
|
33
39
|
export { takeRightWhile } from './takeRightWhile.js';
|
|
34
40
|
export { takeWhile } from './takeWhile.js';
|
|
41
|
+
export { toFilled } from './toFilled.js';
|
|
35
42
|
export { union } from './union.js';
|
|
36
43
|
export { unionBy } from './unionBy.js';
|
|
37
44
|
export { unionWith } from './unionWith.js';
|
|
@@ -40,16 +47,10 @@ export { uniqBy } from './uniqBy.js';
|
|
|
40
47
|
export { uniqWith } from './uniqWith.js';
|
|
41
48
|
export { unzip } from './unzip.js';
|
|
42
49
|
export { unzipWith } from './unzipWith.js';
|
|
50
|
+
export { without } from './without.js';
|
|
43
51
|
export { xor } from './xor.js';
|
|
44
52
|
export { xorBy } from './xorBy.js';
|
|
45
53
|
export { xorWith } from './xorWith.js';
|
|
46
54
|
export { zip } from './zip.js';
|
|
47
55
|
export { zipObject } from './zipObject.js';
|
|
48
56
|
export { zipWith } from './zipWith.js';
|
|
49
|
-
export { without } from './without.js';
|
|
50
|
-
export { head } from './head.js';
|
|
51
|
-
export { isSubset } from './isSubset.js';
|
|
52
|
-
export { tail } from './tail.js';
|
|
53
|
-
export { toFilled } from './toFilled.js';
|
|
54
|
-
export { last } from './last.js';
|
|
55
|
-
export { initial } from './initial.js';
|
package/dist/array/index.js
CHANGED
|
@@ -2,64 +2,93 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const zipWith = require('../_chunk/zipWith-CYaH1Y.js');
|
|
6
6
|
|
|
7
|
-
function
|
|
8
|
-
|
|
7
|
+
function compareValues(a, b, order) {
|
|
8
|
+
if (a < b) {
|
|
9
|
+
return order === 'asc' ? -1 : 1;
|
|
10
|
+
}
|
|
11
|
+
if (a > b) {
|
|
12
|
+
return order === 'asc' ? 1 : -1;
|
|
13
|
+
}
|
|
14
|
+
return 0;
|
|
9
15
|
}
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
exports.
|
|
34
|
-
exports.
|
|
35
|
-
exports.
|
|
36
|
-
exports.
|
|
37
|
-
exports.
|
|
38
|
-
exports.
|
|
39
|
-
exports.
|
|
40
|
-
exports.
|
|
41
|
-
exports.
|
|
42
|
-
exports.
|
|
43
|
-
exports.
|
|
44
|
-
exports.
|
|
45
|
-
exports.
|
|
46
|
-
exports.
|
|
47
|
-
exports.
|
|
48
|
-
exports.
|
|
49
|
-
exports.
|
|
50
|
-
exports.
|
|
51
|
-
exports.
|
|
52
|
-
exports.
|
|
53
|
-
exports.
|
|
54
|
-
exports.
|
|
55
|
-
exports.
|
|
56
|
-
exports.
|
|
57
|
-
exports.
|
|
58
|
-
exports.
|
|
59
|
-
exports.
|
|
60
|
-
exports.
|
|
61
|
-
exports.
|
|
62
|
-
exports.
|
|
63
|
-
exports.
|
|
64
|
-
exports.
|
|
65
|
-
exports.
|
|
17
|
+
function orderBy(arr, criteria, orders) {
|
|
18
|
+
return arr.slice().sort((a, b) => {
|
|
19
|
+
const ordersLength = orders.length;
|
|
20
|
+
for (let i = 0; i < criteria.length; i++) {
|
|
21
|
+
const order = ordersLength > i ? orders[i] : orders[ordersLength - 1];
|
|
22
|
+
const criterion = criteria[i];
|
|
23
|
+
const criterionIsFunction = typeof criterion === 'function';
|
|
24
|
+
const valueA = criterionIsFunction ? criterion(a) : a[criterion];
|
|
25
|
+
const valueB = criterionIsFunction ? criterion(b) : b[criterion];
|
|
26
|
+
const result = compareValues(valueA, valueB, order);
|
|
27
|
+
if (result !== 0) {
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return 0;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function sortBy(arr, criteria) {
|
|
36
|
+
return orderBy(arr, criteria, ['asc']);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
exports.at = zipWith.at;
|
|
40
|
+
exports.chunk = zipWith.chunk;
|
|
41
|
+
exports.compact = zipWith.compact;
|
|
42
|
+
exports.countBy = zipWith.countBy;
|
|
43
|
+
exports.difference = zipWith.difference;
|
|
44
|
+
exports.differenceBy = zipWith.differenceBy;
|
|
45
|
+
exports.differenceWith = zipWith.differenceWith;
|
|
46
|
+
exports.drop = zipWith.drop;
|
|
47
|
+
exports.dropRight = zipWith.dropRight;
|
|
48
|
+
exports.dropRightWhile = zipWith.dropRightWhile;
|
|
49
|
+
exports.dropWhile = zipWith.dropWhile;
|
|
50
|
+
exports.fill = zipWith.fill;
|
|
51
|
+
exports.flatMap = zipWith.flatMap;
|
|
52
|
+
exports.flatMapDeep = zipWith.flatMapDeep;
|
|
53
|
+
exports.flatten = zipWith.flatten;
|
|
54
|
+
exports.flattenDeep = zipWith.flattenDeep;
|
|
55
|
+
exports.forEachRight = zipWith.forEachRight;
|
|
56
|
+
exports.groupBy = zipWith.groupBy;
|
|
57
|
+
exports.head = zipWith.head;
|
|
58
|
+
exports.initial = zipWith.initial;
|
|
59
|
+
exports.intersection = zipWith.intersection;
|
|
60
|
+
exports.intersectionBy = zipWith.intersectionBy;
|
|
61
|
+
exports.intersectionWith = zipWith.intersectionWith;
|
|
62
|
+
exports.isSubset = zipWith.isSubset;
|
|
63
|
+
exports.keyBy = zipWith.keyBy;
|
|
64
|
+
exports.last = zipWith.last;
|
|
65
|
+
exports.maxBy = zipWith.maxBy;
|
|
66
|
+
exports.minBy = zipWith.minBy;
|
|
67
|
+
exports.partition = zipWith.partition;
|
|
68
|
+
exports.pullAt = zipWith.pullAt;
|
|
69
|
+
exports.sample = zipWith.sample;
|
|
70
|
+
exports.sampleSize = zipWith.sampleSize;
|
|
71
|
+
exports.shuffle = zipWith.shuffle;
|
|
72
|
+
exports.tail = zipWith.tail;
|
|
73
|
+
exports.take = zipWith.take;
|
|
74
|
+
exports.takeRight = zipWith.takeRight;
|
|
75
|
+
exports.takeRightWhile = zipWith.takeRightWhile;
|
|
76
|
+
exports.takeWhile = zipWith.takeWhile;
|
|
77
|
+
exports.toFilled = zipWith.toFilled;
|
|
78
|
+
exports.union = zipWith.union;
|
|
79
|
+
exports.unionBy = zipWith.unionBy;
|
|
80
|
+
exports.unionWith = zipWith.unionWith;
|
|
81
|
+
exports.uniq = zipWith.uniq;
|
|
82
|
+
exports.uniqBy = zipWith.uniqBy;
|
|
83
|
+
exports.uniqWith = zipWith.uniqWith;
|
|
84
|
+
exports.unzip = zipWith.unzip;
|
|
85
|
+
exports.unzipWith = zipWith.unzipWith;
|
|
86
|
+
exports.without = zipWith.without;
|
|
87
|
+
exports.xor = zipWith.xor;
|
|
88
|
+
exports.xorBy = zipWith.xorBy;
|
|
89
|
+
exports.xorWith = zipWith.xorWith;
|
|
90
|
+
exports.zip = zipWith.zip;
|
|
91
|
+
exports.zipObject = zipWith.zipObject;
|
|
92
|
+
exports.zipWith = zipWith.zipWith;
|
|
93
|
+
exports.orderBy = orderBy;
|
|
94
|
+
exports.sortBy = sortBy;
|
package/dist/array/index.mjs
CHANGED
|
@@ -11,27 +11,34 @@ export { dropRightWhile } from './dropRightWhile.mjs';
|
|
|
11
11
|
export { dropWhile } from './dropWhile.mjs';
|
|
12
12
|
export { fill } from './fill.mjs';
|
|
13
13
|
export { flatMap } from './flatMap.mjs';
|
|
14
|
+
export { flatMapDeep } from './flatMapDeep.mjs';
|
|
14
15
|
export { flatten } from './flatten.mjs';
|
|
15
16
|
export { flattenDeep } from './flattenDeep.mjs';
|
|
16
17
|
export { forEachRight } from './forEachRight.mjs';
|
|
17
18
|
export { groupBy } from './groupBy.mjs';
|
|
19
|
+
export { head } from './head.mjs';
|
|
20
|
+
export { initial } from './initial.mjs';
|
|
18
21
|
export { intersection } from './intersection.mjs';
|
|
19
22
|
export { intersectionBy } from './intersectionBy.mjs';
|
|
20
23
|
export { intersectionWith } from './intersectionWith.mjs';
|
|
24
|
+
export { isSubset } from './isSubset.mjs';
|
|
21
25
|
export { keyBy } from './keyBy.mjs';
|
|
26
|
+
export { last } from './last.mjs';
|
|
22
27
|
export { maxBy } from './maxBy.mjs';
|
|
23
28
|
export { minBy } from './minBy.mjs';
|
|
24
29
|
export { orderBy } from './orderBy.mjs';
|
|
25
30
|
export { partition } from './partition.mjs';
|
|
26
31
|
export { pullAt } from './pullAt.mjs';
|
|
27
|
-
export { sortBy } from './sortBy.mjs';
|
|
28
32
|
export { sample } from './sample.mjs';
|
|
29
33
|
export { sampleSize } from './sampleSize.mjs';
|
|
30
34
|
export { shuffle } from './shuffle.mjs';
|
|
35
|
+
export { sortBy } from './sortBy.mjs';
|
|
36
|
+
export { tail } from './tail.mjs';
|
|
31
37
|
export { take } from './take.mjs';
|
|
32
38
|
export { takeRight } from './takeRight.mjs';
|
|
33
39
|
export { takeRightWhile } from './takeRightWhile.mjs';
|
|
34
40
|
export { takeWhile } from './takeWhile.mjs';
|
|
41
|
+
export { toFilled } from './toFilled.mjs';
|
|
35
42
|
export { union } from './union.mjs';
|
|
36
43
|
export { unionBy } from './unionBy.mjs';
|
|
37
44
|
export { unionWith } from './unionWith.mjs';
|
|
@@ -40,16 +47,10 @@ export { uniqBy } from './uniqBy.mjs';
|
|
|
40
47
|
export { uniqWith } from './uniqWith.mjs';
|
|
41
48
|
export { unzip } from './unzip.mjs';
|
|
42
49
|
export { unzipWith } from './unzipWith.mjs';
|
|
50
|
+
export { without } from './without.mjs';
|
|
43
51
|
export { xor } from './xor.mjs';
|
|
44
52
|
export { xorBy } from './xorBy.mjs';
|
|
45
53
|
export { xorWith } from './xorWith.mjs';
|
|
46
54
|
export { zip } from './zip.mjs';
|
|
47
55
|
export { zipObject } from './zipObject.mjs';
|
|
48
56
|
export { zipWith } from './zipWith.mjs';
|
|
49
|
-
export { without } from './without.mjs';
|
|
50
|
-
export { head } from './head.mjs';
|
|
51
|
-
export { isSubset } from './isSubset.mjs';
|
|
52
|
-
export { tail } from './tail.mjs';
|
|
53
|
-
export { toFilled } from './toFilled.mjs';
|
|
54
|
-
export { last } from './last.mjs';
|
|
55
|
-
export { initial } from './initial.mjs';
|
package/dist/array/last.d.mts
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the last element of an array.
|
|
3
|
+
*
|
|
4
|
+
* This function takes an array and returns the last element of the array.
|
|
5
|
+
* If the array is empty, the function returns `undefined`.
|
|
6
|
+
*
|
|
7
|
+
* Unlike some implementations, this function is optimized for performance
|
|
8
|
+
* by directly accessing the last index of the array.
|
|
9
|
+
*
|
|
10
|
+
* @template T - The type of elements in the array.
|
|
11
|
+
* @param {[...T[], T]} arr - The array from which to get the last element.
|
|
12
|
+
* @returns {T} The last element of the array, or `undefined` if the array is empty.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const arr = [1, 2, 3];
|
|
16
|
+
* const lastElement = last(arr);
|
|
17
|
+
* // lastElement will be 3
|
|
18
|
+
*
|
|
19
|
+
* const emptyArr: number[] = [];
|
|
20
|
+
* const noElement = last(emptyArr);
|
|
21
|
+
* // noElement will be undefined
|
|
22
|
+
*/
|
|
23
|
+
declare function last<T>(arr: readonly [...T[], T]): T;
|
|
1
24
|
/**
|
|
2
25
|
* Returns the last element of an array.
|
|
3
26
|
*
|
|
@@ -20,7 +43,6 @@
|
|
|
20
43
|
* const noElement = last(emptyArr);
|
|
21
44
|
* // noElement will be undefined
|
|
22
45
|
*/
|
|
23
|
-
declare function last<T>(arr: readonly [...T[], T]): T;
|
|
24
46
|
declare function last<T>(arr: readonly T[]): T | undefined;
|
|
25
47
|
|
|
26
48
|
export { last };
|
package/dist/array/last.d.ts
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the last element of an array.
|
|
3
|
+
*
|
|
4
|
+
* This function takes an array and returns the last element of the array.
|
|
5
|
+
* If the array is empty, the function returns `undefined`.
|
|
6
|
+
*
|
|
7
|
+
* Unlike some implementations, this function is optimized for performance
|
|
8
|
+
* by directly accessing the last index of the array.
|
|
9
|
+
*
|
|
10
|
+
* @template T - The type of elements in the array.
|
|
11
|
+
* @param {[...T[], T]} arr - The array from which to get the last element.
|
|
12
|
+
* @returns {T} The last element of the array, or `undefined` if the array is empty.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const arr = [1, 2, 3];
|
|
16
|
+
* const lastElement = last(arr);
|
|
17
|
+
* // lastElement will be 3
|
|
18
|
+
*
|
|
19
|
+
* const emptyArr: number[] = [];
|
|
20
|
+
* const noElement = last(emptyArr);
|
|
21
|
+
* // noElement will be undefined
|
|
22
|
+
*/
|
|
23
|
+
declare function last<T>(arr: readonly [...T[], T]): T;
|
|
1
24
|
/**
|
|
2
25
|
* Returns the last element of an array.
|
|
3
26
|
*
|
|
@@ -20,7 +43,6 @@
|
|
|
20
43
|
* const noElement = last(emptyArr);
|
|
21
44
|
* // noElement will be undefined
|
|
22
45
|
*/
|
|
23
|
-
declare function last<T>(arr: readonly [...T[], T]): T;
|
|
24
46
|
declare function last<T>(arr: readonly T[]): T | undefined;
|
|
25
47
|
|
|
26
48
|
export { last };
|
package/dist/array/maxBy.d.mts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds the element in an array that has the maximum value when applying
|
|
3
|
+
* the `getValue` function to each element.
|
|
4
|
+
*
|
|
5
|
+
* @template T - The type of elements in the array.
|
|
6
|
+
* @param {[T, ...T[]]} items The nonempty array of elements to search.
|
|
7
|
+
* @param {(element: T) => number} getValue A function that selects a numeric value from each element.
|
|
8
|
+
* @returns {T} The element with the maximum value as determined by the `getValue` function.
|
|
9
|
+
* @example
|
|
10
|
+
* maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }
|
|
11
|
+
* maxBy([], x => x.a); // Returns: undefined
|
|
12
|
+
*/
|
|
13
|
+
declare function maxBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
|
|
1
14
|
/**
|
|
2
15
|
* Finds the element in an array that has the maximum value when applying
|
|
3
16
|
* the `getValue` function to each element.
|
|
@@ -10,7 +23,6 @@
|
|
|
10
23
|
* maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }
|
|
11
24
|
* maxBy([], x => x.a); // Returns: undefined
|
|
12
25
|
*/
|
|
13
|
-
declare function maxBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
|
|
14
26
|
declare function maxBy<T>(items: readonly T[], getValue: (element: T) => number): T | undefined;
|
|
15
27
|
|
|
16
28
|
export { maxBy };
|
package/dist/array/maxBy.d.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds the element in an array that has the maximum value when applying
|
|
3
|
+
* the `getValue` function to each element.
|
|
4
|
+
*
|
|
5
|
+
* @template T - The type of elements in the array.
|
|
6
|
+
* @param {[T, ...T[]]} items The nonempty array of elements to search.
|
|
7
|
+
* @param {(element: T) => number} getValue A function that selects a numeric value from each element.
|
|
8
|
+
* @returns {T} The element with the maximum value as determined by the `getValue` function.
|
|
9
|
+
* @example
|
|
10
|
+
* maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }
|
|
11
|
+
* maxBy([], x => x.a); // Returns: undefined
|
|
12
|
+
*/
|
|
13
|
+
declare function maxBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
|
|
1
14
|
/**
|
|
2
15
|
* Finds the element in an array that has the maximum value when applying
|
|
3
16
|
* the `getValue` function to each element.
|
|
@@ -10,7 +23,6 @@
|
|
|
10
23
|
* maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }
|
|
11
24
|
* maxBy([], x => x.a); // Returns: undefined
|
|
12
25
|
*/
|
|
13
|
-
declare function maxBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
|
|
14
26
|
declare function maxBy<T>(items: readonly T[], getValue: (element: T) => number): T | undefined;
|
|
15
27
|
|
|
16
28
|
export { maxBy };
|
package/dist/array/minBy.d.mts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds the element in an array that has the minimum value when applying
|
|
3
|
+
* the `getValue` function to each element.
|
|
4
|
+
*
|
|
5
|
+
* @template T - The type of elements in the array.
|
|
6
|
+
* @param {[T, ...T[]]} items The nonempty array of elements to search.
|
|
7
|
+
* @param {(element: T) => number} getValue A function that selects a numeric value from each element.
|
|
8
|
+
* @returns {T} The element with the minimum value as determined by the `getValue` function.
|
|
9
|
+
* @example
|
|
10
|
+
* minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }
|
|
11
|
+
* minBy([], x => x.a); // Returns: undefined
|
|
12
|
+
*/
|
|
13
|
+
declare function minBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
|
|
1
14
|
/**
|
|
2
15
|
* Finds the element in an array that has the minimum value when applying
|
|
3
16
|
* the `getValue` function to each element.
|
|
@@ -10,7 +23,6 @@
|
|
|
10
23
|
* minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }
|
|
11
24
|
* minBy([], x => x.a); // Returns: undefined
|
|
12
25
|
*/
|
|
13
|
-
declare function minBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
|
|
14
26
|
declare function minBy<T>(items: readonly T[], getValue: (element: T) => number): T | undefined;
|
|
15
27
|
|
|
16
28
|
export { minBy };
|
package/dist/array/minBy.d.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds the element in an array that has the minimum value when applying
|
|
3
|
+
* the `getValue` function to each element.
|
|
4
|
+
*
|
|
5
|
+
* @template T - The type of elements in the array.
|
|
6
|
+
* @param {[T, ...T[]]} items The nonempty array of elements to search.
|
|
7
|
+
* @param {(element: T) => number} getValue A function that selects a numeric value from each element.
|
|
8
|
+
* @returns {T} The element with the minimum value as determined by the `getValue` function.
|
|
9
|
+
* @example
|
|
10
|
+
* minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }
|
|
11
|
+
* minBy([], x => x.a); // Returns: undefined
|
|
12
|
+
*/
|
|
13
|
+
declare function minBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
|
|
1
14
|
/**
|
|
2
15
|
* Finds the element in an array that has the minimum value when applying
|
|
3
16
|
* the `getValue` function to each element.
|
|
@@ -10,7 +23,6 @@
|
|
|
10
23
|
* minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }
|
|
11
24
|
* minBy([], x => x.a); // Returns: undefined
|
|
12
25
|
*/
|
|
13
|
-
declare function minBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
|
|
14
26
|
declare function minBy<T>(items: readonly T[], getValue: (element: T) => number): T | undefined;
|
|
15
27
|
|
|
16
28
|
export { minBy };
|