es-toolkit 1.26.1 → 1.27.0-dev.876

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.
Files changed (109) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/_chunk/{sumBy-RVppiV.js → rangeRight-w3WrXN.js} +2 -14
  3. package/dist/_chunk/{toMerged-wNz52b.js → toMerged-CPY8Ug.js} +7 -1
  4. package/dist/_chunk/{upperFirst-BUECmK.js → upperFirst-DK_rTF.js} +23 -23
  5. package/dist/_chunk/{zipWith-Dkv3D1.js → zipWith-Bb2eZI.js} +19 -5
  6. package/dist/array/at.mjs +7 -2
  7. package/dist/array/index.d.mts +1 -0
  8. package/dist/array/index.d.ts +1 -0
  9. package/dist/array/index.js +2 -1
  10. package/dist/array/index.mjs +1 -0
  11. package/dist/array/isSubsetWith.d.mts +33 -0
  12. package/dist/array/isSubsetWith.d.ts +33 -0
  13. package/dist/array/isSubsetWith.mjs +7 -0
  14. package/dist/array/without.mjs +3 -2
  15. package/dist/array/zip.mjs +6 -1
  16. package/dist/browser.global.js +1 -1
  17. package/dist/browser.global.js.map +1 -1
  18. package/dist/compat/_internal/flattenArrayLike.mjs +17 -0
  19. package/dist/compat/_internal/isPrototype.mjs +7 -0
  20. package/dist/compat/_internal/toArray.mjs +5 -0
  21. package/dist/compat/array/chunk.mjs +2 -1
  22. package/dist/compat/array/difference.mjs +2 -1
  23. package/dist/compat/array/differenceBy.d.mts +82 -0
  24. package/dist/compat/array/differenceBy.d.ts +82 -0
  25. package/dist/compat/array/differenceBy.mjs +20 -0
  26. package/dist/compat/array/drop.mjs +2 -1
  27. package/dist/compat/array/dropRight.mjs +2 -1
  28. package/dist/compat/array/dropWhile.mjs +2 -1
  29. package/dist/compat/array/findLastIndex.mjs +2 -1
  30. package/dist/compat/array/forEach.d.mts +106 -0
  31. package/dist/compat/array/forEach.d.ts +106 -0
  32. package/dist/compat/array/forEach.mjs +21 -0
  33. package/dist/compat/array/head.mjs +2 -1
  34. package/dist/compat/array/last.mjs +2 -1
  35. package/dist/compat/array/sample.mjs +2 -1
  36. package/dist/compat/array/tail.mjs +2 -1
  37. package/dist/compat/array/take.mjs +2 -1
  38. package/dist/compat/array/takeRight.mjs +2 -1
  39. package/dist/compat/array/union.d.mts +30 -0
  40. package/dist/compat/array/union.d.ts +30 -0
  41. package/dist/compat/array/union.mjs +11 -0
  42. package/dist/compat/array/uniqBy.d.mts +60 -0
  43. package/dist/compat/array/uniqBy.d.ts +60 -0
  44. package/dist/compat/array/uniqBy.mjs +25 -0
  45. package/dist/compat/array/unzip.d.mts +16 -0
  46. package/dist/compat/array/unzip.d.ts +16 -0
  47. package/dist/compat/array/unzip.mjs +14 -0
  48. package/dist/compat/array/zip.d.mts +134 -0
  49. package/dist/compat/array/zip.d.ts +134 -0
  50. package/dist/compat/array/zip.mjs +11 -0
  51. package/dist/compat/index.d.mts +15 -8
  52. package/dist/compat/index.d.ts +15 -8
  53. package/dist/compat/index.js +312 -104
  54. package/dist/compat/index.mjs +15 -8
  55. package/dist/compat/math/sum.d.mts +37 -0
  56. package/dist/compat/math/sum.d.ts +37 -0
  57. package/dist/compat/math/sum.mjs +7 -0
  58. package/dist/compat/math/sumBy.d.mts +64 -0
  59. package/dist/compat/math/sumBy.d.ts +64 -0
  60. package/dist/compat/math/sumBy.mjs +20 -0
  61. package/dist/compat/predicate/isEmpty.d.mts +78 -0
  62. package/dist/compat/predicate/isEmpty.d.ts +78 -0
  63. package/dist/compat/predicate/isEmpty.mjs +33 -0
  64. package/dist/compat/string/replace.d.mts +17 -0
  65. package/dist/compat/string/replace.d.ts +17 -0
  66. package/dist/compat/string/replace.mjs +10 -0
  67. package/dist/compat/string/startCase.mjs +4 -4
  68. package/dist/compat/util/iteratee.d.mts +44 -0
  69. package/dist/compat/util/iteratee.d.ts +44 -0
  70. package/dist/compat/util/iteratee.mjs +28 -0
  71. package/dist/compat/util/toPath.mjs +56 -25
  72. package/dist/index.d.mts +3 -0
  73. package/dist/index.d.ts +3 -0
  74. package/dist/index.js +17 -14
  75. package/dist/index.mjs +3 -0
  76. package/dist/math/index.js +19 -11
  77. package/dist/math/range.mjs +1 -4
  78. package/dist/math/rangeRight.mjs +1 -4
  79. package/dist/math/sumBy.mjs +5 -4
  80. package/dist/object/cloneDeep.mjs +1 -1
  81. package/dist/object/findKey.d.mts +21 -0
  82. package/dist/object/findKey.d.ts +21 -0
  83. package/dist/object/findKey.mjs +6 -0
  84. package/dist/object/index.d.mts +1 -0
  85. package/dist/object/index.d.ts +1 -0
  86. package/dist/object/index.js +2 -1
  87. package/dist/object/index.mjs +1 -0
  88. package/dist/object/mapKeys.d.mts +4 -5
  89. package/dist/object/mapKeys.d.ts +4 -5
  90. package/dist/object/mergeWith.d.mts +1 -1
  91. package/dist/object/mergeWith.d.ts +1 -1
  92. package/dist/object/toMerged.d.mts +1 -1
  93. package/dist/object/toMerged.d.ts +1 -1
  94. package/dist/string/camelCase.mjs +4 -4
  95. package/dist/string/constantCase.mjs +3 -3
  96. package/dist/string/index.d.mts +1 -0
  97. package/dist/string/index.d.ts +1 -0
  98. package/dist/string/index.js +3 -2
  99. package/dist/string/index.mjs +1 -0
  100. package/dist/string/kebabCase.mjs +3 -3
  101. package/dist/string/lowerCase.mjs +3 -3
  102. package/dist/string/pascalCase.mjs +3 -3
  103. package/dist/string/snakeCase.mjs +3 -3
  104. package/dist/string/startCase.mjs +4 -4
  105. package/dist/string/upperCase.mjs +5 -5
  106. package/dist/string/words.d.mts +20 -0
  107. package/dist/string/words.d.ts +20 -0
  108. package/dist/string/{_internal/getWords.mjs → words.mjs} +2 -2
  109. package/package.json +1 -1
@@ -0,0 +1,30 @@
1
+ /**
2
+ * This function takes multiple arrays and returns a new array containing only the unique values
3
+ * from all input arrays, preserving the order of their first occurrence.
4
+ *
5
+ * @template T - The type of elements in the arrays.
6
+ * @param {Array<ArrayLike<T> | null | undefined>} arrays - The arrays to inspect.
7
+ * @returns {T[]} Returns the new array of combined unique values.
8
+ *
9
+ * @example
10
+ * // Returns [2, 1]
11
+ * union([2], [1, 2]);
12
+ *
13
+ * @example
14
+ * // Returns [2, 1, 3]
15
+ * union([2], [1, 2], [2, 3]);
16
+ *
17
+ * @example
18
+ * // Returns [1, 3, 2, [5], [4]] (does not deeply flatten nested arrays)
19
+ * union([1, 3, 2], [1, [5]], [2, [4]]);
20
+ *
21
+ * @example
22
+ * // Returns [0, 2, 1] (ignores non-array values like 3 and { '0': 1 })
23
+ * union([0], 3, { '0': 1 }, null, [2, 1]);
24
+ * @example
25
+ * // Returns [0, 'a', 2, 1] (treats array-like object { 0: 'a', length: 1 } as a valid array)
26
+ * union([0], { 0: 'a', length: 1 }, [2, 1]);
27
+ */
28
+ declare function union<T>(...arrays: Array<ArrayLike<T> | null | undefined>): T[];
29
+
30
+ export { union };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * This function takes multiple arrays and returns a new array containing only the unique values
3
+ * from all input arrays, preserving the order of their first occurrence.
4
+ *
5
+ * @template T - The type of elements in the arrays.
6
+ * @param {Array<ArrayLike<T> | null | undefined>} arrays - The arrays to inspect.
7
+ * @returns {T[]} Returns the new array of combined unique values.
8
+ *
9
+ * @example
10
+ * // Returns [2, 1]
11
+ * union([2], [1, 2]);
12
+ *
13
+ * @example
14
+ * // Returns [2, 1, 3]
15
+ * union([2], [1, 2], [2, 3]);
16
+ *
17
+ * @example
18
+ * // Returns [1, 3, 2, [5], [4]] (does not deeply flatten nested arrays)
19
+ * union([1, 3, 2], [1, [5]], [2, [4]]);
20
+ *
21
+ * @example
22
+ * // Returns [0, 2, 1] (ignores non-array values like 3 and { '0': 1 })
23
+ * union([0], 3, { '0': 1 }, null, [2, 1]);
24
+ * @example
25
+ * // Returns [0, 'a', 2, 1] (treats array-like object { 0: 'a', length: 1 } as a valid array)
26
+ * union([0], { 0: 'a', length: 1 }, [2, 1]);
27
+ */
28
+ declare function union<T>(...arrays: Array<ArrayLike<T> | null | undefined>): T[];
29
+
30
+ export { union };
@@ -0,0 +1,11 @@
1
+ import { flatten } from './flatten.mjs';
2
+ import { uniq } from '../../array/uniq.mjs';
3
+ import { isArrayLikeObject } from '../predicate/isArrayLikeObject.mjs';
4
+
5
+ function union(...arrays) {
6
+ const validArrays = arrays.filter(isArrayLikeObject);
7
+ const flattened = flatten(validArrays, 1);
8
+ return uniq(flattened);
9
+ }
10
+
11
+ export { union };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Creates a duplicate-free version of an array using a transform function for comparison.
3
+ *
4
+ * @template T
5
+ * @param {ArrayLike<T>} array - The array to inspect.
6
+ * @param {(value: T) => unknown} iteratee - The transform function.
7
+ * @returns {T[]} Returns the new duplicate-free array.
8
+ *
9
+ * @example
10
+ * uniqBy([2.1, 1.2, 2.3], Math.floor);
11
+ * // => [2.1, 1.2]
12
+ */
13
+ declare function uniqBy<T>(array: ArrayLike<T>, iteratee: (value: T) => unknown): T[];
14
+ /**
15
+ * Creates a duplicate-free version of an array using a property name for comparison.
16
+ *
17
+ * @template T
18
+ * @param {ArrayLike<T>} array - The array to inspect.
19
+ * @param {string} path - The property path to get values from.
20
+ * @returns {T[]} Returns the new duplicate-free array.
21
+ *
22
+ * @example
23
+ * const users = [
24
+ * { 'user': 'barney', 'age': 36 },
25
+ * { 'user': 'fred', 'age': 40 },
26
+ * { 'user': 'barney', 'age': 37 }
27
+ * ];
28
+ * uniqBy(users, 'user');
29
+ * // => [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }]
30
+ */
31
+ declare function uniqBy<T>(array: ArrayLike<T>, path: string): T[];
32
+ /**
33
+ * Creates a duplicate-free version of an array using a property index for comparison.
34
+ *
35
+ * @template T
36
+ * @param {ArrayLike<T>} array - The array to inspect.
37
+ * @param {number} index - The index to get values from.
38
+ * @returns {T[]} Returns the new duplicate-free array.
39
+ *
40
+ * @example
41
+ * const arrays = [[2], [3], [1], [2], [3], [1]];
42
+ * uniqBy(arrays, 0);
43
+ * // => [[2], [3], [1]]
44
+ */
45
+ declare function uniqBy<T>(array: ArrayLike<T>, index: number): T[];
46
+ /**
47
+ * Creates a duplicate-free version of an array, combining multiple arrays and using an optional transform function.
48
+ *
49
+ * @template T
50
+ * @param {ArrayLike<T>} array - The array to inspect.
51
+ * @param {...Array<ArrayLike<T> | ((value: T) => unknown) | string>} values - Additional arrays and/or iteratee.
52
+ * @returns {T[]} Returns the new duplicate-free array.
53
+ *
54
+ * @example
55
+ * uniqBy([1, 2], [2, 3], [3, 4], Math.floor);
56
+ * // => [1, 2, 3, 4]
57
+ */
58
+ declare function uniqBy<T>(array: ArrayLike<T> | null | undefined, ...values: Array<ArrayLike<T> | ((value: T) => unknown) | string>): T[];
59
+
60
+ export { uniqBy };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Creates a duplicate-free version of an array using a transform function for comparison.
3
+ *
4
+ * @template T
5
+ * @param {ArrayLike<T>} array - The array to inspect.
6
+ * @param {(value: T) => unknown} iteratee - The transform function.
7
+ * @returns {T[]} Returns the new duplicate-free array.
8
+ *
9
+ * @example
10
+ * uniqBy([2.1, 1.2, 2.3], Math.floor);
11
+ * // => [2.1, 1.2]
12
+ */
13
+ declare function uniqBy<T>(array: ArrayLike<T>, iteratee: (value: T) => unknown): T[];
14
+ /**
15
+ * Creates a duplicate-free version of an array using a property name for comparison.
16
+ *
17
+ * @template T
18
+ * @param {ArrayLike<T>} array - The array to inspect.
19
+ * @param {string} path - The property path to get values from.
20
+ * @returns {T[]} Returns the new duplicate-free array.
21
+ *
22
+ * @example
23
+ * const users = [
24
+ * { 'user': 'barney', 'age': 36 },
25
+ * { 'user': 'fred', 'age': 40 },
26
+ * { 'user': 'barney', 'age': 37 }
27
+ * ];
28
+ * uniqBy(users, 'user');
29
+ * // => [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }]
30
+ */
31
+ declare function uniqBy<T>(array: ArrayLike<T>, path: string): T[];
32
+ /**
33
+ * Creates a duplicate-free version of an array using a property index for comparison.
34
+ *
35
+ * @template T
36
+ * @param {ArrayLike<T>} array - The array to inspect.
37
+ * @param {number} index - The index to get values from.
38
+ * @returns {T[]} Returns the new duplicate-free array.
39
+ *
40
+ * @example
41
+ * const arrays = [[2], [3], [1], [2], [3], [1]];
42
+ * uniqBy(arrays, 0);
43
+ * // => [[2], [3], [1]]
44
+ */
45
+ declare function uniqBy<T>(array: ArrayLike<T>, index: number): T[];
46
+ /**
47
+ * Creates a duplicate-free version of an array, combining multiple arrays and using an optional transform function.
48
+ *
49
+ * @template T
50
+ * @param {ArrayLike<T>} array - The array to inspect.
51
+ * @param {...Array<ArrayLike<T> | ((value: T) => unknown) | string>} values - Additional arrays and/or iteratee.
52
+ * @returns {T[]} Returns the new duplicate-free array.
53
+ *
54
+ * @example
55
+ * uniqBy([1, 2], [2, 3], [3, 4], Math.floor);
56
+ * // => [1, 2, 3, 4]
57
+ */
58
+ declare function uniqBy<T>(array: ArrayLike<T> | null | undefined, ...values: Array<ArrayLike<T> | ((value: T) => unknown) | string>): T[];
59
+
60
+ export { uniqBy };
@@ -0,0 +1,25 @@
1
+ import { flatten } from './flatten.mjs';
2
+ import { last } from './last.mjs';
3
+ import { uniq } from '../../array/uniq.mjs';
4
+ import { uniqBy as uniqBy$1 } from '../../array/uniqBy.mjs';
5
+ import { isArrayLikeObject } from '../predicate/isArrayLikeObject.mjs';
6
+ import { iteratee } from '../util/iteratee.mjs';
7
+
8
+ function uniqBy(arr, ...values) {
9
+ if (!isArrayLikeObject(arr)) {
10
+ return [];
11
+ }
12
+ const iteratee$1 = last(values);
13
+ if (iteratee$1 === undefined) {
14
+ return Array.from(arr);
15
+ }
16
+ const validArrays = values.slice(0, -1).filter(isArrayLikeObject);
17
+ const flattenedArrays = flatten(validArrays);
18
+ const allValues = [...Array.from(arr), ...flattenedArrays];
19
+ if (isArrayLikeObject(iteratee$1)) {
20
+ return uniq(allValues);
21
+ }
22
+ return uniqBy$1(allValues, iteratee(iteratee$1));
23
+ }
24
+
25
+ export { uniqBy };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Gathers elements in the same position in an internal array
3
+ * from a grouped array of elements and returns them as a new array.
4
+ *
5
+ * @template T - The type of elements in the nested array.
6
+ * @param {T[][] | ArrayLike<ArrayLike<T>> | null | undefined} array - The nested array to unzip.
7
+ * @returns {T[][]} A new array of unzipped elements.
8
+ *
9
+ * @example
10
+ * const zipped = [['a', true, 1],['b', false, 2]];
11
+ * const result = unzip(zipped);
12
+ * // result will be [['a', 'b'], [true, false], [1, 2]]
13
+ */
14
+ declare function unzip<T>(array: T[][] | ArrayLike<ArrayLike<T>> | null | undefined): T[][];
15
+
16
+ export { unzip };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Gathers elements in the same position in an internal array
3
+ * from a grouped array of elements and returns them as a new array.
4
+ *
5
+ * @template T - The type of elements in the nested array.
6
+ * @param {T[][] | ArrayLike<ArrayLike<T>> | null | undefined} array - The nested array to unzip.
7
+ * @returns {T[][]} A new array of unzipped elements.
8
+ *
9
+ * @example
10
+ * const zipped = [['a', true, 1],['b', false, 2]];
11
+ * const result = unzip(zipped);
12
+ * // result will be [['a', 'b'], [true, false], [1, 2]]
13
+ */
14
+ declare function unzip<T>(array: T[][] | ArrayLike<ArrayLike<T>> | null | undefined): T[][];
15
+
16
+ export { unzip };
@@ -0,0 +1,14 @@
1
+ import { unzip as unzip$1 } from '../../array/unzip.mjs';
2
+ import { isArrayLikeObject } from '../predicate/isArrayLikeObject.mjs';
3
+
4
+ function unzip(array) {
5
+ if (!isArrayLikeObject(array) || !array.length) {
6
+ return [];
7
+ }
8
+ if (Array.isArray(array)) {
9
+ return unzip$1(array);
10
+ }
11
+ return unzip$1(Array.from(array, value => Array.from(value)));
12
+ }
13
+
14
+ export { unzip };
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Combines multiple arrays into a single array of tuples.
3
+ *
4
+ * This function takes multiple arrays and returns a new array where each element is a tuple
5
+ * containing the corresponding elements from the input arrays. If the input arrays are of
6
+ * different lengths, the resulting array will have the length of the longest input array,
7
+ * with undefined values for missing elements.
8
+ *
9
+ * @template T
10
+ * @param {ArrayLike<T>} arr1 - The first array to zip.
11
+ * @returns {Array<[T | undefined]>} 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: ArrayLike<T>): Array<[T | undefined]>;
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 {ArrayLike<T>} arr1 - The first array to zip.
29
+ * @param {ArrayLike<U>} arr2 - The second array to zip.
30
+ * @returns {Array<[T | undefined, U | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.
31
+ *
32
+ * @example
33
+ * const arr1 = [1, 2, 3];
34
+ * const arr2 = ['a', 'b', 'c'];
35
+ * const result = zip(arr1, arr2);
36
+ * // result will be [[1, 'a'], [2, 'b'], [3, 'c']]
37
+ */
38
+ declare function zip<T, U>(arr1: ArrayLike<T>, arr2: ArrayLike<U>): Array<[T | undefined, U | undefined]>;
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 {ArrayLike<T>} arr1 - The first array to zip.
49
+ * @param {ArrayLike<U>} arr2 - The second array to zip.
50
+ * @param {ArrayLike<V>} arr3 - The third array to zip.
51
+ * @returns {Array<[T | undefined, U | undefined, V | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.
52
+ *
53
+ * @example
54
+ * const arr1 = [1, 2, 3];
55
+ * const arr2 = ['a', 'b', 'c'];
56
+ * const arr3 = [true, false];
57
+ * const result = zip(arr1, arr2, arr3);
58
+ * // result will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]]
59
+ */
60
+ declare function zip<T, U, V>(arr1: ArrayLike<T>, arr2: ArrayLike<U>, arr3: ArrayLike<V>): Array<[T | undefined, U | undefined, V | undefined]>;
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 {ArrayLike<T>} arr1 - The first array to zip.
71
+ * @param {ArrayLike<U>} arr2 - The second array to zip.
72
+ * @param {ArrayLike<V>} arr3 - The third array to zip.
73
+ * @param {ArrayLike<W>} arr4 - The fourth array to zip.
74
+ * @returns {Array<[T | undefined, U | undefined, V | undefined, W | undefined]>} 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
+ */
84
+ declare function zip<T, U, V, W>(arr1: ArrayLike<T>, arr2: ArrayLike<U>, arr3: ArrayLike<V>, arr4: ArrayLike<W>): Array<[T | undefined, U | undefined, V | undefined, W | undefined]>;
85
+ /**
86
+ * Combines multiple arrays into a single array of tuples.
87
+ *
88
+ * This function takes multiple arrays and returns a new array where each element is a tuple
89
+ * containing the corresponding elements from the input arrays. If the input arrays are of
90
+ * different lengths, the resulting array will have the length of the longest input array,
91
+ * with undefined values for missing elements.
92
+ *
93
+ * @template T, U, V, W
94
+ * @param {ArrayLike<T>} arr1 - The first array to zip.
95
+ * @param {ArrayLike<U>} arr2 - The second array to zip.
96
+ * @param {ArrayLike<V>} arr3 - The third array to zip.
97
+ * @param {ArrayLike<W>} arr4 - The fourth array to zip.
98
+ * @param {ArrayLike<X>} arr5 - The fifth array to zip.
99
+ * @returns {Array<[T | undefined, U | undefined, V | undefined, W | undefined, X | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.
100
+ *
101
+ * @example
102
+ * const arr1 = [1, 2, 3];
103
+ * const arr2 = ['a', 'b', 'c'];
104
+ * const arr3 = [true, false];
105
+ * const arr4 = [null, null, null];
106
+ * const arr5 = [undefined, undefined, undefined];
107
+ * const result = zip(arr1, arr2, arr3, arr4, arr5);
108
+ * // result will be [[1, 'a', true, null, undefined], [2, 'b', false, null, undefined], [3, 'c', undefined, null, undefined]]
109
+ */
110
+ declare function zip<T, U, V, W, X>(arr1: ArrayLike<T>, arr2: ArrayLike<U>, arr3: ArrayLike<V>, arr4: ArrayLike<W>, arr5: ArrayLike<X>): Array<[T | undefined, U | undefined, V | undefined, W | undefined, X | undefined]>;
111
+ /**
112
+ * Combines multiple arrays into a single array of tuples.
113
+ *
114
+ * This function takes multiple arrays and returns a new array where each element is a tuple
115
+ * containing the corresponding elements from the input arrays. If the input arrays are of
116
+ * different lengths, the resulting array will have the length of the longest input array,
117
+ * with undefined values for missing elements.
118
+ *
119
+ * @template T
120
+ * @param {Array<ArrayLike<any> | null | undefined>} arrays - The arrays to zip.
121
+ * @returns {Array<Array<T | undefined>>} A new array of tuples containing the corresponding elements from the input arrays.
122
+ *
123
+ * @example
124
+ * const arr1 = [1, 2, 3];
125
+ * const arr2 = ['a', 'b', 'c'];
126
+ * const arr3 = [true, false];
127
+ * const arr4 = [null, null, null];
128
+ * const arr5 = [undefined, undefined, undefined];
129
+ * const result = zip(arr1, arr2, arr3, arr4, arr5);
130
+ * // result will be [[1, 'a', true, null, undefined], [2, 'b', false, null, undefined], [3, 'c', undefined, null, undefined]]
131
+ */
132
+ declare function zip<T>(...arrays: Array<ArrayLike<any> | null | undefined>): Array<Array<T | undefined>>;
133
+
134
+ export { zip };
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Combines multiple arrays into a single array of tuples.
3
+ *
4
+ * This function takes multiple arrays and returns a new array where each element is a tuple
5
+ * containing the corresponding elements from the input arrays. If the input arrays are of
6
+ * different lengths, the resulting array will have the length of the longest input array,
7
+ * with undefined values for missing elements.
8
+ *
9
+ * @template T
10
+ * @param {ArrayLike<T>} arr1 - The first array to zip.
11
+ * @returns {Array<[T | undefined]>} 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: ArrayLike<T>): Array<[T | undefined]>;
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 {ArrayLike<T>} arr1 - The first array to zip.
29
+ * @param {ArrayLike<U>} arr2 - The second array to zip.
30
+ * @returns {Array<[T | undefined, U | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.
31
+ *
32
+ * @example
33
+ * const arr1 = [1, 2, 3];
34
+ * const arr2 = ['a', 'b', 'c'];
35
+ * const result = zip(arr1, arr2);
36
+ * // result will be [[1, 'a'], [2, 'b'], [3, 'c']]
37
+ */
38
+ declare function zip<T, U>(arr1: ArrayLike<T>, arr2: ArrayLike<U>): Array<[T | undefined, U | undefined]>;
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 {ArrayLike<T>} arr1 - The first array to zip.
49
+ * @param {ArrayLike<U>} arr2 - The second array to zip.
50
+ * @param {ArrayLike<V>} arr3 - The third array to zip.
51
+ * @returns {Array<[T | undefined, U | undefined, V | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.
52
+ *
53
+ * @example
54
+ * const arr1 = [1, 2, 3];
55
+ * const arr2 = ['a', 'b', 'c'];
56
+ * const arr3 = [true, false];
57
+ * const result = zip(arr1, arr2, arr3);
58
+ * // result will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]]
59
+ */
60
+ declare function zip<T, U, V>(arr1: ArrayLike<T>, arr2: ArrayLike<U>, arr3: ArrayLike<V>): Array<[T | undefined, U | undefined, V | undefined]>;
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 {ArrayLike<T>} arr1 - The first array to zip.
71
+ * @param {ArrayLike<U>} arr2 - The second array to zip.
72
+ * @param {ArrayLike<V>} arr3 - The third array to zip.
73
+ * @param {ArrayLike<W>} arr4 - The fourth array to zip.
74
+ * @returns {Array<[T | undefined, U | undefined, V | undefined, W | undefined]>} 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
+ */
84
+ declare function zip<T, U, V, W>(arr1: ArrayLike<T>, arr2: ArrayLike<U>, arr3: ArrayLike<V>, arr4: ArrayLike<W>): Array<[T | undefined, U | undefined, V | undefined, W | undefined]>;
85
+ /**
86
+ * Combines multiple arrays into a single array of tuples.
87
+ *
88
+ * This function takes multiple arrays and returns a new array where each element is a tuple
89
+ * containing the corresponding elements from the input arrays. If the input arrays are of
90
+ * different lengths, the resulting array will have the length of the longest input array,
91
+ * with undefined values for missing elements.
92
+ *
93
+ * @template T, U, V, W
94
+ * @param {ArrayLike<T>} arr1 - The first array to zip.
95
+ * @param {ArrayLike<U>} arr2 - The second array to zip.
96
+ * @param {ArrayLike<V>} arr3 - The third array to zip.
97
+ * @param {ArrayLike<W>} arr4 - The fourth array to zip.
98
+ * @param {ArrayLike<X>} arr5 - The fifth array to zip.
99
+ * @returns {Array<[T | undefined, U | undefined, V | undefined, W | undefined, X | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.
100
+ *
101
+ * @example
102
+ * const arr1 = [1, 2, 3];
103
+ * const arr2 = ['a', 'b', 'c'];
104
+ * const arr3 = [true, false];
105
+ * const arr4 = [null, null, null];
106
+ * const arr5 = [undefined, undefined, undefined];
107
+ * const result = zip(arr1, arr2, arr3, arr4, arr5);
108
+ * // result will be [[1, 'a', true, null, undefined], [2, 'b', false, null, undefined], [3, 'c', undefined, null, undefined]]
109
+ */
110
+ declare function zip<T, U, V, W, X>(arr1: ArrayLike<T>, arr2: ArrayLike<U>, arr3: ArrayLike<V>, arr4: ArrayLike<W>, arr5: ArrayLike<X>): Array<[T | undefined, U | undefined, V | undefined, W | undefined, X | undefined]>;
111
+ /**
112
+ * Combines multiple arrays into a single array of tuples.
113
+ *
114
+ * This function takes multiple arrays and returns a new array where each element is a tuple
115
+ * containing the corresponding elements from the input arrays. If the input arrays are of
116
+ * different lengths, the resulting array will have the length of the longest input array,
117
+ * with undefined values for missing elements.
118
+ *
119
+ * @template T
120
+ * @param {Array<ArrayLike<any> | null | undefined>} arrays - The arrays to zip.
121
+ * @returns {Array<Array<T | undefined>>} A new array of tuples containing the corresponding elements from the input arrays.
122
+ *
123
+ * @example
124
+ * const arr1 = [1, 2, 3];
125
+ * const arr2 = ['a', 'b', 'c'];
126
+ * const arr3 = [true, false];
127
+ * const arr4 = [null, null, null];
128
+ * const arr5 = [undefined, undefined, undefined];
129
+ * const result = zip(arr1, arr2, arr3, arr4, arr5);
130
+ * // result will be [[1, 'a', true, null, undefined], [2, 'b', false, null, undefined], [3, 'c', undefined, null, undefined]]
131
+ */
132
+ declare function zip<T>(...arrays: Array<ArrayLike<any> | null | undefined>): Array<Array<T | undefined>>;
133
+
134
+ export { zip };
@@ -0,0 +1,11 @@
1
+ import { zip as zip$1 } from '../../array/zip.mjs';
2
+ import { isArrayLikeObject } from '../predicate/isArrayLikeObject.mjs';
3
+
4
+ function zip(...arrays) {
5
+ if (!arrays.length) {
6
+ return [];
7
+ }
8
+ return zip$1(...arrays.filter(group => isArrayLikeObject(group)));
9
+ }
10
+
11
+ export { zip };