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
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
* @template U - The type of the value to fill the new array with.
|
|
7
7
|
* @param {Array<T>} arr - The array to base the new array on.
|
|
8
8
|
* @param {U} value - The value to fill the new array with.
|
|
9
|
-
* @param {number} [start=0] - The start position. Defaults to 0.
|
|
10
|
-
* @param {number} [end=arr.length] - The end position. Defaults to the array's length.
|
|
11
9
|
* @returns {Array<T | U>} The new array with the filled values.
|
|
12
10
|
*
|
|
13
11
|
* @example
|
|
@@ -29,7 +27,66 @@
|
|
|
29
27
|
* console.log(array); // [1, 2, 3, 4, 5]
|
|
30
28
|
*/
|
|
31
29
|
declare function toFilled<T, U>(arr: readonly T[], value: U): Array<T | U>;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new array filled with the specified value from the start position up to, but not including, the end position.
|
|
32
|
+
* This function does not mutate the original array.
|
|
33
|
+
*
|
|
34
|
+
* @template T - The type of elements in the original array.
|
|
35
|
+
* @template U - The type of the value to fill the new array with.
|
|
36
|
+
* @param {Array<T>} arr - The array to base the new array on.
|
|
37
|
+
* @param {U} value - The value to fill the new array with.
|
|
38
|
+
* @param {number} [start=0] - The start position. Defaults to 0.
|
|
39
|
+
* @returns {Array<T | U>} The new array with the filled values.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* const array = [1, 2, 3, 4, 5];
|
|
43
|
+
* let result = toFilled(array, '*', 2);
|
|
44
|
+
* console.log(result); // [1, 2, '*', '*', '*']
|
|
45
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
46
|
+
*
|
|
47
|
+
* result = toFilled(array, '*', 1, 4);
|
|
48
|
+
* console.log(result); // [1, '*', '*', '*', 5]
|
|
49
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
50
|
+
*
|
|
51
|
+
* result = toFilled(array, '*');
|
|
52
|
+
* console.log(result); // ['*', '*', '*', '*', '*']
|
|
53
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
54
|
+
*
|
|
55
|
+
* result = toFilled(array, '*', -4, -1);
|
|
56
|
+
* console.log(result); // [1, '*', '*', '*', 5]
|
|
57
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
58
|
+
*/
|
|
32
59
|
declare function toFilled<T, U>(arr: readonly T[], value: U, start: number): Array<T | U>;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a new array filled with the specified value from the start position up to, but not including, the end position.
|
|
62
|
+
* This function does not mutate the original array.
|
|
63
|
+
*
|
|
64
|
+
* @template T - The type of elements in the original array.
|
|
65
|
+
* @template U - The type of the value to fill the new array with.
|
|
66
|
+
* @param {Array<T>} arr - The array to base the new array on.
|
|
67
|
+
* @param {U} value - The value to fill the new array with.
|
|
68
|
+
* @param {number} [start=0] - The start position. Defaults to 0.
|
|
69
|
+
* @param {number} [end=arr.length] - The end position. Defaults to the array's length.
|
|
70
|
+
* @returns {Array<T | U>} The new array with the filled values.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* const array = [1, 2, 3, 4, 5];
|
|
74
|
+
* let result = toFilled(array, '*', 2);
|
|
75
|
+
* console.log(result); // [1, 2, '*', '*', '*']
|
|
76
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
77
|
+
*
|
|
78
|
+
* result = toFilled(array, '*', 1, 4);
|
|
79
|
+
* console.log(result); // [1, '*', '*', '*', 5]
|
|
80
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
81
|
+
*
|
|
82
|
+
* result = toFilled(array, '*');
|
|
83
|
+
* console.log(result); // ['*', '*', '*', '*', '*']
|
|
84
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
85
|
+
*
|
|
86
|
+
* result = toFilled(array, '*', -4, -1);
|
|
87
|
+
* console.log(result); // [1, '*', '*', '*', 5]
|
|
88
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
89
|
+
*/
|
|
33
90
|
declare function toFilled<T, U>(arr: readonly T[], value: U, start: number, end: number): Array<T | U>;
|
|
34
91
|
|
|
35
92
|
export { toFilled };
|
package/dist/array/toFilled.d.ts
CHANGED
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
* @template U - The type of the value to fill the new array with.
|
|
7
7
|
* @param {Array<T>} arr - The array to base the new array on.
|
|
8
8
|
* @param {U} value - The value to fill the new array with.
|
|
9
|
-
* @param {number} [start=0] - The start position. Defaults to 0.
|
|
10
|
-
* @param {number} [end=arr.length] - The end position. Defaults to the array's length.
|
|
11
9
|
* @returns {Array<T | U>} The new array with the filled values.
|
|
12
10
|
*
|
|
13
11
|
* @example
|
|
@@ -29,7 +27,66 @@
|
|
|
29
27
|
* console.log(array); // [1, 2, 3, 4, 5]
|
|
30
28
|
*/
|
|
31
29
|
declare function toFilled<T, U>(arr: readonly T[], value: U): Array<T | U>;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new array filled with the specified value from the start position up to, but not including, the end position.
|
|
32
|
+
* This function does not mutate the original array.
|
|
33
|
+
*
|
|
34
|
+
* @template T - The type of elements in the original array.
|
|
35
|
+
* @template U - The type of the value to fill the new array with.
|
|
36
|
+
* @param {Array<T>} arr - The array to base the new array on.
|
|
37
|
+
* @param {U} value - The value to fill the new array with.
|
|
38
|
+
* @param {number} [start=0] - The start position. Defaults to 0.
|
|
39
|
+
* @returns {Array<T | U>} The new array with the filled values.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* const array = [1, 2, 3, 4, 5];
|
|
43
|
+
* let result = toFilled(array, '*', 2);
|
|
44
|
+
* console.log(result); // [1, 2, '*', '*', '*']
|
|
45
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
46
|
+
*
|
|
47
|
+
* result = toFilled(array, '*', 1, 4);
|
|
48
|
+
* console.log(result); // [1, '*', '*', '*', 5]
|
|
49
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
50
|
+
*
|
|
51
|
+
* result = toFilled(array, '*');
|
|
52
|
+
* console.log(result); // ['*', '*', '*', '*', '*']
|
|
53
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
54
|
+
*
|
|
55
|
+
* result = toFilled(array, '*', -4, -1);
|
|
56
|
+
* console.log(result); // [1, '*', '*', '*', 5]
|
|
57
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
58
|
+
*/
|
|
32
59
|
declare function toFilled<T, U>(arr: readonly T[], value: U, start: number): Array<T | U>;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a new array filled with the specified value from the start position up to, but not including, the end position.
|
|
62
|
+
* This function does not mutate the original array.
|
|
63
|
+
*
|
|
64
|
+
* @template T - The type of elements in the original array.
|
|
65
|
+
* @template U - The type of the value to fill the new array with.
|
|
66
|
+
* @param {Array<T>} arr - The array to base the new array on.
|
|
67
|
+
* @param {U} value - The value to fill the new array with.
|
|
68
|
+
* @param {number} [start=0] - The start position. Defaults to 0.
|
|
69
|
+
* @param {number} [end=arr.length] - The end position. Defaults to the array's length.
|
|
70
|
+
* @returns {Array<T | U>} The new array with the filled values.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* const array = [1, 2, 3, 4, 5];
|
|
74
|
+
* let result = toFilled(array, '*', 2);
|
|
75
|
+
* console.log(result); // [1, 2, '*', '*', '*']
|
|
76
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
77
|
+
*
|
|
78
|
+
* result = toFilled(array, '*', 1, 4);
|
|
79
|
+
* console.log(result); // [1, '*', '*', '*', 5]
|
|
80
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
81
|
+
*
|
|
82
|
+
* result = toFilled(array, '*');
|
|
83
|
+
* console.log(result); // ['*', '*', '*', '*', '*']
|
|
84
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
85
|
+
*
|
|
86
|
+
* result = toFilled(array, '*', -4, -1);
|
|
87
|
+
* console.log(result); // [1, '*', '*', '*', 5]
|
|
88
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
89
|
+
*/
|
|
33
90
|
declare function toFilled<T, U>(arr: readonly T[], value: U, start: number, end: number): Array<T | U>;
|
|
34
91
|
|
|
35
92
|
export { toFilled };
|
package/dist/array/zip.d.mts
CHANGED
|
@@ -6,23 +6,81 @@
|
|
|
6
6
|
* different lengths, the resulting array will have the length of the longest input array,
|
|
7
7
|
* with undefined values for missing elements.
|
|
8
8
|
*
|
|
9
|
-
* @
|
|
10
|
-
* @param arr1
|
|
11
|
-
* @returns {T
|
|
9
|
+
* @template T
|
|
10
|
+
* @param {T[]} arr1 - The first array to zip.
|
|
11
|
+
* @returns {Array<[T]>} A new array of tuples containing the corresponding elements from the input arrays.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const arr1 = [1, 2, 3];
|
|
15
|
+
* const result = zip(arr1);
|
|
16
|
+
* // result will be [[1], [2], [3]]
|
|
17
|
+
*/
|
|
18
|
+
declare function zip<T>(arr1: readonly T[]): Array<[T]>;
|
|
19
|
+
/**
|
|
20
|
+
* Combines multiple arrays into a single array of tuples.
|
|
21
|
+
*
|
|
22
|
+
* This function takes multiple arrays and returns a new array where each element is a tuple
|
|
23
|
+
* containing the corresponding elements from the input arrays. If the input arrays are of
|
|
24
|
+
* different lengths, the resulting array will have the length of the longest input array,
|
|
25
|
+
* with undefined values for missing elements.
|
|
26
|
+
*
|
|
27
|
+
* @template T, U
|
|
28
|
+
* @param {T[]} arr1 - The first array to zip.
|
|
29
|
+
* @param {U[]} arr2 - The second array to zip.
|
|
30
|
+
* @returns {Array<[T, U]>} A new array of tuples containing the corresponding elements from the input arrays.
|
|
12
31
|
*
|
|
13
32
|
* @example
|
|
14
33
|
* const arr1 = [1, 2, 3];
|
|
15
34
|
* const arr2 = ['a', 'b', 'c'];
|
|
16
35
|
* const result = zip(arr1, arr2);
|
|
17
36
|
* // result will be [[1, 'a'], [2, 'b'], [3, 'c']]
|
|
37
|
+
*/
|
|
38
|
+
declare function zip<T, U>(arr1: readonly T[], arr2: readonly U[]): Array<[T, U]>;
|
|
39
|
+
/**
|
|
40
|
+
* Combines multiple arrays into a single array of tuples.
|
|
41
|
+
*
|
|
42
|
+
* This function takes multiple arrays and returns a new array where each element is a tuple
|
|
43
|
+
* containing the corresponding elements from the input arrays. If the input arrays are of
|
|
44
|
+
* different lengths, the resulting array will have the length of the longest input array,
|
|
45
|
+
* with undefined values for missing elements.
|
|
46
|
+
*
|
|
47
|
+
* @template T, U, V
|
|
48
|
+
* @param {T[]} arr1 - The first array to zip.
|
|
49
|
+
* @param {U[]} arr2 - The second array to zip.
|
|
50
|
+
* @param {V[]} arr3 - The third array to zip.
|
|
51
|
+
* @returns {Array<[T, U, V]>} A new array of tuples containing the corresponding elements from the input arrays.
|
|
18
52
|
*
|
|
53
|
+
* @example
|
|
54
|
+
* const arr1 = [1, 2, 3];
|
|
55
|
+
* const arr2 = ['a', 'b', 'c'];
|
|
19
56
|
* const arr3 = [true, false];
|
|
20
|
-
* const
|
|
21
|
-
* //
|
|
57
|
+
* const result = zip(arr1, arr2, arr3);
|
|
58
|
+
* // result will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]]
|
|
22
59
|
*/
|
|
23
|
-
declare function zip<T>(arr1: readonly T[]): Array<[T]>;
|
|
24
|
-
declare function zip<T, U>(arr1: readonly T[], arr2: readonly U[]): Array<[T, U]>;
|
|
25
60
|
declare function zip<T, U, V>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[]): Array<[T, U, V]>;
|
|
61
|
+
/**
|
|
62
|
+
* Combines multiple arrays into a single array of tuples.
|
|
63
|
+
*
|
|
64
|
+
* This function takes multiple arrays and returns a new array where each element is a tuple
|
|
65
|
+
* containing the corresponding elements from the input arrays. If the input arrays are of
|
|
66
|
+
* different lengths, the resulting array will have the length of the longest input array,
|
|
67
|
+
* with undefined values for missing elements.
|
|
68
|
+
*
|
|
69
|
+
* @template T, U, V, W
|
|
70
|
+
* @param {T[]} arr1 - The first array to zip.
|
|
71
|
+
* @param {U[]} arr2 - The second array to zip.
|
|
72
|
+
* @param {V[]} arr3 - The third array to zip.
|
|
73
|
+
* @param {W[]} arr4 - The fourth array to zip.
|
|
74
|
+
* @returns {Array<[T, U, V, W]>} A new array of tuples containing the corresponding elements from the input arrays.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* const arr1 = [1, 2, 3];
|
|
78
|
+
* const arr2 = ['a', 'b', 'c'];
|
|
79
|
+
* const arr3 = [true, false];
|
|
80
|
+
* const arr4 = [null, null, null];
|
|
81
|
+
* const result = zip(arr1, arr2, arr3, arr4);
|
|
82
|
+
* // result will be [[1, 'a', true, null], [2, 'b', false, null], [3, 'c', undefined, null]]
|
|
83
|
+
*/
|
|
26
84
|
declare function zip<T, U, V, W>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[], arr4: readonly W[]): Array<[T, U, V, W]>;
|
|
27
85
|
|
|
28
86
|
export { zip };
|
package/dist/array/zip.d.ts
CHANGED
|
@@ -6,23 +6,81 @@
|
|
|
6
6
|
* different lengths, the resulting array will have the length of the longest input array,
|
|
7
7
|
* with undefined values for missing elements.
|
|
8
8
|
*
|
|
9
|
-
* @
|
|
10
|
-
* @param arr1
|
|
11
|
-
* @returns {T
|
|
9
|
+
* @template T
|
|
10
|
+
* @param {T[]} arr1 - The first array to zip.
|
|
11
|
+
* @returns {Array<[T]>} A new array of tuples containing the corresponding elements from the input arrays.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const arr1 = [1, 2, 3];
|
|
15
|
+
* const result = zip(arr1);
|
|
16
|
+
* // result will be [[1], [2], [3]]
|
|
17
|
+
*/
|
|
18
|
+
declare function zip<T>(arr1: readonly T[]): Array<[T]>;
|
|
19
|
+
/**
|
|
20
|
+
* Combines multiple arrays into a single array of tuples.
|
|
21
|
+
*
|
|
22
|
+
* This function takes multiple arrays and returns a new array where each element is a tuple
|
|
23
|
+
* containing the corresponding elements from the input arrays. If the input arrays are of
|
|
24
|
+
* different lengths, the resulting array will have the length of the longest input array,
|
|
25
|
+
* with undefined values for missing elements.
|
|
26
|
+
*
|
|
27
|
+
* @template T, U
|
|
28
|
+
* @param {T[]} arr1 - The first array to zip.
|
|
29
|
+
* @param {U[]} arr2 - The second array to zip.
|
|
30
|
+
* @returns {Array<[T, U]>} A new array of tuples containing the corresponding elements from the input arrays.
|
|
12
31
|
*
|
|
13
32
|
* @example
|
|
14
33
|
* const arr1 = [1, 2, 3];
|
|
15
34
|
* const arr2 = ['a', 'b', 'c'];
|
|
16
35
|
* const result = zip(arr1, arr2);
|
|
17
36
|
* // result will be [[1, 'a'], [2, 'b'], [3, 'c']]
|
|
37
|
+
*/
|
|
38
|
+
declare function zip<T, U>(arr1: readonly T[], arr2: readonly U[]): Array<[T, U]>;
|
|
39
|
+
/**
|
|
40
|
+
* Combines multiple arrays into a single array of tuples.
|
|
41
|
+
*
|
|
42
|
+
* This function takes multiple arrays and returns a new array where each element is a tuple
|
|
43
|
+
* containing the corresponding elements from the input arrays. If the input arrays are of
|
|
44
|
+
* different lengths, the resulting array will have the length of the longest input array,
|
|
45
|
+
* with undefined values for missing elements.
|
|
46
|
+
*
|
|
47
|
+
* @template T, U, V
|
|
48
|
+
* @param {T[]} arr1 - The first array to zip.
|
|
49
|
+
* @param {U[]} arr2 - The second array to zip.
|
|
50
|
+
* @param {V[]} arr3 - The third array to zip.
|
|
51
|
+
* @returns {Array<[T, U, V]>} A new array of tuples containing the corresponding elements from the input arrays.
|
|
18
52
|
*
|
|
53
|
+
* @example
|
|
54
|
+
* const arr1 = [1, 2, 3];
|
|
55
|
+
* const arr2 = ['a', 'b', 'c'];
|
|
19
56
|
* const arr3 = [true, false];
|
|
20
|
-
* const
|
|
21
|
-
* //
|
|
57
|
+
* const result = zip(arr1, arr2, arr3);
|
|
58
|
+
* // result will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]]
|
|
22
59
|
*/
|
|
23
|
-
declare function zip<T>(arr1: readonly T[]): Array<[T]>;
|
|
24
|
-
declare function zip<T, U>(arr1: readonly T[], arr2: readonly U[]): Array<[T, U]>;
|
|
25
60
|
declare function zip<T, U, V>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[]): Array<[T, U, V]>;
|
|
61
|
+
/**
|
|
62
|
+
* Combines multiple arrays into a single array of tuples.
|
|
63
|
+
*
|
|
64
|
+
* This function takes multiple arrays and returns a new array where each element is a tuple
|
|
65
|
+
* containing the corresponding elements from the input arrays. If the input arrays are of
|
|
66
|
+
* different lengths, the resulting array will have the length of the longest input array,
|
|
67
|
+
* with undefined values for missing elements.
|
|
68
|
+
*
|
|
69
|
+
* @template T, U, V, W
|
|
70
|
+
* @param {T[]} arr1 - The first array to zip.
|
|
71
|
+
* @param {U[]} arr2 - The second array to zip.
|
|
72
|
+
* @param {V[]} arr3 - The third array to zip.
|
|
73
|
+
* @param {W[]} arr4 - The fourth array to zip.
|
|
74
|
+
* @returns {Array<[T, U, V, W]>} A new array of tuples containing the corresponding elements from the input arrays.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* const arr1 = [1, 2, 3];
|
|
78
|
+
* const arr2 = ['a', 'b', 'c'];
|
|
79
|
+
* const arr3 = [true, false];
|
|
80
|
+
* const arr4 = [null, null, null];
|
|
81
|
+
* const result = zip(arr1, arr2, arr3, arr4);
|
|
82
|
+
* // result will be [[1, 'a', true, null], [2, 'b', false, null], [3, 'c', undefined, null]]
|
|
83
|
+
*/
|
|
26
84
|
declare function zip<T, U, V, W>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[], arr4: readonly W[]): Array<[T, U, V, W]>;
|
|
27
85
|
|
|
28
86
|
export { zip };
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @template V - The type of elements in the array.
|
|
11
11
|
* @param {P[]} keys - An array of property names.
|
|
12
12
|
* @param {V[]} values - An array of values corresponding to the property names.
|
|
13
|
-
* @returns {
|
|
13
|
+
* @returns {Record<P, V>} - A new object composed of the given property names and values.
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* const keys = ['a', 'b', 'c'];
|
|
@@ -28,8 +28,6 @@
|
|
|
28
28
|
* const result2 = zipObject(keys2, values2);
|
|
29
29
|
* // result2 will be { a: 1, b: 2 }
|
|
30
30
|
*/
|
|
31
|
-
declare function zipObject<P extends PropertyKey, V>(keys: P[], values: V[]):
|
|
32
|
-
[K in P]: V;
|
|
33
|
-
};
|
|
31
|
+
declare function zipObject<P extends PropertyKey, V>(keys: P[], values: V[]): Record<P, V>;
|
|
34
32
|
|
|
35
33
|
export { zipObject };
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @template V - The type of elements in the array.
|
|
11
11
|
* @param {P[]} keys - An array of property names.
|
|
12
12
|
* @param {V[]} values - An array of values corresponding to the property names.
|
|
13
|
-
* @returns {
|
|
13
|
+
* @returns {Record<P, V>} - A new object composed of the given property names and values.
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* const keys = ['a', 'b', 'c'];
|
|
@@ -28,8 +28,6 @@
|
|
|
28
28
|
* const result2 = zipObject(keys2, values2);
|
|
29
29
|
* // result2 will be { a: 1, b: 2 }
|
|
30
30
|
*/
|
|
31
|
-
declare function zipObject<P extends PropertyKey, V>(keys: P[], values: V[]):
|
|
32
|
-
[K in P]: V;
|
|
33
|
-
};
|
|
31
|
+
declare function zipObject<P extends PropertyKey, V>(keys: P[], values: V[]): Record<P, V>;
|
|
34
32
|
|
|
35
33
|
export { zipObject };
|
package/dist/array/zipWith.d.mts
CHANGED
|
@@ -5,14 +5,8 @@
|
|
|
5
5
|
* is the result of applying the combiner function to the corresponding elements of the input arrays.
|
|
6
6
|
*
|
|
7
7
|
* @template T - The type of elements in the first array.
|
|
8
|
-
* @template U - The type of elements in the second array (optional).
|
|
9
|
-
* @template V - The type of elements in the third array (optional).
|
|
10
|
-
* @template W - The type of elements in the fourth array (optional).
|
|
11
8
|
* @template R - The type of elements in the resulting array.
|
|
12
9
|
* @param {T[]} arr1 - The first array to zip.
|
|
13
|
-
* @param {U[]} [arr2] - The second array to zip (optional).
|
|
14
|
-
* @param {V[]} [arr3] - The third array to zip (optional).
|
|
15
|
-
* @param {W[]} [arr4] - The fourth array to zip (optional).
|
|
16
10
|
* @param {(...items: T[]) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.
|
|
17
11
|
* @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
|
|
18
12
|
*
|
|
@@ -32,8 +26,47 @@
|
|
|
32
26
|
* // result will be [`135`, `246`]
|
|
33
27
|
*/
|
|
34
28
|
declare function zipWith<T, R>(arr1: readonly T[], combine: (item: T) => R): R[];
|
|
29
|
+
/**
|
|
30
|
+
* Combines two arrays into a single array using a custom combiner function.
|
|
31
|
+
*
|
|
32
|
+
* @template T - The type of elements in the first array.
|
|
33
|
+
* @template U - The type of elements in the second array.
|
|
34
|
+
* @template R - The type of elements in the resulting array.
|
|
35
|
+
* @param {T[]} arr1 - The first array to zip.
|
|
36
|
+
* @param {U[]} arr2 - The second array to zip.
|
|
37
|
+
* @param {(item1: T, item2: U) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.
|
|
38
|
+
* @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
|
|
39
|
+
*/
|
|
35
40
|
declare function zipWith<T, U, R>(arr1: readonly T[], arr2: readonly U[], combine: (item1: T, item2: U) => R): R[];
|
|
41
|
+
/**
|
|
42
|
+
* Combines three arrays into a single array using a custom combiner function.
|
|
43
|
+
*
|
|
44
|
+
* @template T - The type of elements in the first array.
|
|
45
|
+
* @template U - The type of elements in the second array.
|
|
46
|
+
* @template V - The type of elements in the third array.
|
|
47
|
+
* @template R - The type of elements in the resulting array.
|
|
48
|
+
* @param {T[]} arr1 - The first array to zip.
|
|
49
|
+
* @param {U[]} arr2 - The second array to zip.
|
|
50
|
+
* @param {V[]} arr3 - The third array to zip.
|
|
51
|
+
* @param {(item1: T, item2: U, item3: V) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.
|
|
52
|
+
* @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
|
|
53
|
+
*/
|
|
36
54
|
declare function zipWith<T, U, V, R>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[], combine: (item1: T, item2: U, item3: V) => R): R[];
|
|
55
|
+
/**
|
|
56
|
+
* Combines four arrays into a single array using a custom combiner function.
|
|
57
|
+
*
|
|
58
|
+
* @template T - The type of elements in the first array.
|
|
59
|
+
* @template U - The type of elements in the second array.
|
|
60
|
+
* @template V - The type of elements in the third array.
|
|
61
|
+
* @template W - The type of elements in the fourth array.
|
|
62
|
+
* @template R - The type of elements in the resulting array.
|
|
63
|
+
* @param {T[]} arr1 - The first array to zip.
|
|
64
|
+
* @param {U[]} arr2 - The second array to zip.
|
|
65
|
+
* @param {V[]} arr3 - The third array to zip.
|
|
66
|
+
* @param {W[]} arr4 - The fourth array to zip.
|
|
67
|
+
* @param {(item1: T, item2: U, item3: V, item4: W) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.
|
|
68
|
+
* @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
|
|
69
|
+
*/
|
|
37
70
|
declare function zipWith<T, U, V, W, R>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[], arr4: readonly W[], combine: (item1: T, item2: U, item3: V, item4: W) => R): R[];
|
|
38
71
|
|
|
39
72
|
export { zipWith };
|
package/dist/array/zipWith.d.ts
CHANGED
|
@@ -5,14 +5,8 @@
|
|
|
5
5
|
* is the result of applying the combiner function to the corresponding elements of the input arrays.
|
|
6
6
|
*
|
|
7
7
|
* @template T - The type of elements in the first array.
|
|
8
|
-
* @template U - The type of elements in the second array (optional).
|
|
9
|
-
* @template V - The type of elements in the third array (optional).
|
|
10
|
-
* @template W - The type of elements in the fourth array (optional).
|
|
11
8
|
* @template R - The type of elements in the resulting array.
|
|
12
9
|
* @param {T[]} arr1 - The first array to zip.
|
|
13
|
-
* @param {U[]} [arr2] - The second array to zip (optional).
|
|
14
|
-
* @param {V[]} [arr3] - The third array to zip (optional).
|
|
15
|
-
* @param {W[]} [arr4] - The fourth array to zip (optional).
|
|
16
10
|
* @param {(...items: T[]) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.
|
|
17
11
|
* @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
|
|
18
12
|
*
|
|
@@ -32,8 +26,47 @@
|
|
|
32
26
|
* // result will be [`135`, `246`]
|
|
33
27
|
*/
|
|
34
28
|
declare function zipWith<T, R>(arr1: readonly T[], combine: (item: T) => R): R[];
|
|
29
|
+
/**
|
|
30
|
+
* Combines two arrays into a single array using a custom combiner function.
|
|
31
|
+
*
|
|
32
|
+
* @template T - The type of elements in the first array.
|
|
33
|
+
* @template U - The type of elements in the second array.
|
|
34
|
+
* @template R - The type of elements in the resulting array.
|
|
35
|
+
* @param {T[]} arr1 - The first array to zip.
|
|
36
|
+
* @param {U[]} arr2 - The second array to zip.
|
|
37
|
+
* @param {(item1: T, item2: U) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.
|
|
38
|
+
* @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
|
|
39
|
+
*/
|
|
35
40
|
declare function zipWith<T, U, R>(arr1: readonly T[], arr2: readonly U[], combine: (item1: T, item2: U) => R): R[];
|
|
41
|
+
/**
|
|
42
|
+
* Combines three arrays into a single array using a custom combiner function.
|
|
43
|
+
*
|
|
44
|
+
* @template T - The type of elements in the first array.
|
|
45
|
+
* @template U - The type of elements in the second array.
|
|
46
|
+
* @template V - The type of elements in the third array.
|
|
47
|
+
* @template R - The type of elements in the resulting array.
|
|
48
|
+
* @param {T[]} arr1 - The first array to zip.
|
|
49
|
+
* @param {U[]} arr2 - The second array to zip.
|
|
50
|
+
* @param {V[]} arr3 - The third array to zip.
|
|
51
|
+
* @param {(item1: T, item2: U, item3: V) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.
|
|
52
|
+
* @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
|
|
53
|
+
*/
|
|
36
54
|
declare function zipWith<T, U, V, R>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[], combine: (item1: T, item2: U, item3: V) => R): R[];
|
|
55
|
+
/**
|
|
56
|
+
* Combines four arrays into a single array using a custom combiner function.
|
|
57
|
+
*
|
|
58
|
+
* @template T - The type of elements in the first array.
|
|
59
|
+
* @template U - The type of elements in the second array.
|
|
60
|
+
* @template V - The type of elements in the third array.
|
|
61
|
+
* @template W - The type of elements in the fourth array.
|
|
62
|
+
* @template R - The type of elements in the resulting array.
|
|
63
|
+
* @param {T[]} arr1 - The first array to zip.
|
|
64
|
+
* @param {U[]} arr2 - The second array to zip.
|
|
65
|
+
* @param {V[]} arr3 - The third array to zip.
|
|
66
|
+
* @param {W[]} arr4 - The fourth array to zip.
|
|
67
|
+
* @param {(item1: T, item2: U, item3: V, item4: W) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.
|
|
68
|
+
* @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
|
|
69
|
+
*/
|
|
37
70
|
declare function zipWith<T, U, V, W, R>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[], arr4: readonly W[], combine: (item1: T, item2: U, item3: V, item4: W) => R): R[];
|
|
38
71
|
|
|
39
72
|
export { zipWith };
|