source: node_modules/es-toolkit/dist/compat/array/zip.d.ts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 8.7 KB
RevLine 
[a762898]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, U
10 * @param {ArrayLike<T>} arr1 - The first array to zip.
11 * @param {ArrayLike<U>} arr2 - The second array to zip.
12 * @returns {Array<[T | undefined, U | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.
13 *
14 * @example
15 * const arr1 = [1, 2, 3];
16 * const arr2 = ['a', 'b', 'c'];
17 * const result = zip(arr1, arr2);
18 * // result will be [[1, 'a'], [2, 'b'], [3, 'c']]
19 */
20/**
21 * Creates an array of grouped elements, the first of which contains the first elements of the given arrays,
22 * the second of which contains the second elements of the given arrays, and so on.
23 *
24 * @template T, U
25 * @param {ArrayLike<T>} arr1 - The first array to zip.
26 * @param {ArrayLike<U>} arr2 - The second array to zip.
27 * @returns {Array<[T | undefined, U | undefined]>} Returns the new array of grouped elements.
28 *
29 * @example
30 * zip([1, 2], ['a', 'b']);
31 * // => [[1, 'a'], [2, 'b']]
32 */
33declare function zip<T, U>(arr1: ArrayLike<T>, arr2: ArrayLike<U>): Array<[T | undefined, U | undefined]>;
34/**
35 * Combines multiple arrays into a single array of tuples.
36 *
37 * This function takes multiple arrays and returns a new array where each element is a tuple
38 * containing the corresponding elements from the input arrays. If the input arrays are of
39 * different lengths, the resulting array will have the length of the longest input array,
40 * with undefined values for missing elements.
41 *
42 * @template T, U, V
43 * @param {ArrayLike<T>} arr1 - The first array to zip.
44 * @param {ArrayLike<U>} arr2 - The second array to zip.
45 * @param {ArrayLike<V>} arr3 - The third array to zip.
46 * @returns {Array<[T | undefined, U | undefined, V | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.
47 *
48 * @example
49 * const arr1 = [1, 2, 3];
50 * const arr2 = ['a', 'b', 'c'];
51 * const arr3 = [true, false];
52 * const result = zip(arr1, arr2, arr3);
53 * // result will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]]
54 */
55/**
56 * Creates an array of grouped elements, the first of which contains the first elements of the given arrays,
57 * the second of which contains the second elements of the given arrays, and so on.
58 *
59 * @template T, U, V
60 * @param {ArrayLike<T>} arr1 - The first array to zip.
61 * @param {ArrayLike<U>} arr2 - The second array to zip.
62 * @param {ArrayLike<V>} arr3 - The third array to zip.
63 * @returns {Array<[T | undefined, U | undefined, V | undefined]>} Returns the new array of grouped elements.
64 *
65 * @example
66 * zip([1, 2], ['a', 'b'], [true, false]);
67 * // => [[1, 'a', true], [2, 'b', false]]
68 */
69declare function zip<T, U, V>(arr1: ArrayLike<T>, arr2: ArrayLike<U>, arr3: ArrayLike<V>): Array<[T | undefined, U | undefined, V | undefined]>;
70/**
71 * Combines multiple arrays into a single array of tuples.
72 *
73 * This function takes multiple arrays and returns a new array where each element is a tuple
74 * containing the corresponding elements from the input arrays. If the input arrays are of
75 * different lengths, the resulting array will have the length of the longest input array,
76 * with undefined values for missing elements.
77 *
78 * @template T, U, V, W
79 * @param {ArrayLike<T>} arr1 - The first array to zip.
80 * @param {ArrayLike<U>} arr2 - The second array to zip.
81 * @param {ArrayLike<V>} arr3 - The third array to zip.
82 * @param {ArrayLike<W>} arr4 - The fourth array to zip.
83 * @returns {Array<[T | undefined, U | undefined, V | undefined, W | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.
84 *
85 * @example
86 * const arr1 = [1, 2, 3];
87 * const arr2 = ['a', 'b', 'c'];
88 * const arr3 = [true, false];
89 * const arr4 = [null, null, null];
90 * const result = zip(arr1, arr2, arr3, arr4);
91 * // result will be [[1, 'a', true, null], [2, 'b', false, null], [3, 'c', undefined, null]]
92 */
93/**
94 * Creates an array of grouped elements, the first of which contains the first elements of the given arrays,
95 * the second of which contains the second elements of the given arrays, and so on.
96 *
97 * @template T, U, V, W
98 * @param {ArrayLike<T>} arr1 - The first array to zip.
99 * @param {ArrayLike<U>} arr2 - The second array to zip.
100 * @param {ArrayLike<V>} arr3 - The third array to zip.
101 * @param {ArrayLike<W>} arr4 - The fourth array to zip.
102 * @returns {Array<[T | undefined, U | undefined, V | undefined, W | undefined]>} Returns the new array of grouped elements.
103 *
104 * @example
105 * zip([1], ['a'], [true], [null]);
106 * // => [[1, 'a', true, null]]
107 */
108declare 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]>;
109/**
110 * Combines multiple arrays into a single array of tuples.
111 *
112 * This function takes multiple arrays and returns a new array where each element is a tuple
113 * containing the corresponding elements from the input arrays. If the input arrays are of
114 * different lengths, the resulting array will have the length of the longest input array,
115 * with undefined values for missing elements.
116 *
117 * @template T, U, V, W
118 * @param {ArrayLike<T>} arr1 - The first array to zip.
119 * @param {ArrayLike<U>} arr2 - The second array to zip.
120 * @param {ArrayLike<V>} arr3 - The third array to zip.
121 * @param {ArrayLike<W>} arr4 - The fourth array to zip.
122 * @param {ArrayLike<X>} arr5 - The fifth array to zip.
123 * @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.
124 *
125 * @example
126 * const arr1 = [1, 2, 3];
127 * const arr2 = ['a', 'b', 'c'];
128 * const arr3 = [true, false];
129 * const arr4 = [null, null, null];
130 * const arr5 = [undefined, undefined, undefined];
131 * const result = zip(arr1, arr2, arr3, arr4, arr5);
132 * // result will be [[1, 'a', true, null, undefined], [2, 'b', false, null, undefined], [3, 'c', undefined, null, undefined]]
133 */
134/**
135 * Creates an array of grouped elements, the first of which contains the first elements of the given arrays,
136 * the second of which contains the second elements of the given arrays, and so on.
137 *
138 * @template T, U, V, W, X
139 * @param {ArrayLike<T>} arr1 - The first array to zip.
140 * @param {ArrayLike<U>} arr2 - The second array to zip.
141 * @param {ArrayLike<V>} arr3 - The third array to zip.
142 * @param {ArrayLike<W>} arr4 - The fourth array to zip.
143 * @param {ArrayLike<X>} arr5 - The fifth array to zip.
144 * @returns {Array<[T | undefined, U | undefined, V | undefined, W | undefined, X | undefined]>} Returns the new array of grouped elements.
145 *
146 * @example
147 * zip([1], ['a'], [true], [null], [undefined]);
148 * // => [[1, 'a', true, null, undefined]]
149 */
150declare 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]>;
151/**
152 * Combines multiple arrays into a single array of tuples.
153 *
154 * This function takes multiple arrays and returns a new array where each element is a tuple
155 * containing the corresponding elements from the input arrays. If the input arrays are of
156 * different lengths, the resulting array will have the length of the longest input array,
157 * with undefined values for missing elements.
158 *
159 * @template T
160 * @param {Array<ArrayLike<any> | null | undefined>} arrays - The arrays to zip.
161 * @returns {Array<Array<T | undefined>>} A new array of tuples containing the corresponding elements from the input arrays.
162 *
163 * @example
164 * const arr1 = [1, 2, 3];
165 * const arr2 = ['a', 'b', 'c'];
166 * const arr3 = [true, false];
167 * const arr4 = [null, null, null];
168 * const arr5 = [undefined, undefined, undefined];
169 * const result = zip(arr1, arr2, arr3, arr4, arr5);
170 * // result will be [[1, 'a', true, null, undefined], [2, 'b', false, null, undefined], [3, 'c', undefined, null, undefined]]
171 */
172/**
173 * Creates an array of grouped elements, the first of which contains the first elements of the given arrays,
174 * the second of which contains the second elements of the given arrays, and so on.
175 *
176 * @template T
177 * @param {...Array<ArrayLike<T> | null | undefined>} arrays - The arrays to process.
178 * @returns {Array<Array<T | undefined>>} Returns the new array of grouped elements.
179 *
180 * @example
181 * zip([1, 2], ['a', 'b'], [true, false]);
182 * // => [[1, 'a', true], [2, 'b', false]]
183 */
184declare function zip<T>(...arrays: Array<ArrayLike<T> | null | undefined>): Array<Array<T | undefined>>;
185
186export { zip };
Note: See TracBrowser for help on using the repository browser.