source: node_modules/es-toolkit/dist/array/zipWith.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: 4.1 KB
Line 
1/**
2 * Combines multiple arrays into a single array using a custom combiner function.
3 *
4 * This function takes multiple arrays and a combiner function, and returns a new array where each element
5 * is the result of applying the combiner function to the corresponding elements of the input arrays.
6 *
7 * @template T - The type of elements in the first array.
8 * @template R - The type of elements in the resulting array.
9 * @param {T[]} arr1 - The first array to zip.
10 * @param {(item: T, index: number) => R} combine - The combiner function that takes corresponding elements from each array, their index, and returns a single value.
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.
12 *
13 * @example
14 * // Example usage with two arrays:
15 * const arr1 = [1, 2, 3];
16 * const arr2 = [4, 5, 6];
17 * const result = zipWith(arr1, arr2, (a, b) => a + b);
18 * // result will be [5, 7, 9]
19 *
20 * @example
21 * // Example usage with three arrays:
22 * const arr1 = [1, 2];
23 * const arr2 = [3, 4];
24 * const arr3 = [5, 6];
25 * const result = zipWith(arr1, arr2, arr3, (a, b, c) => `${a}${b}${c}`);
26 * // result will be [`135`, `246`]
27 */
28declare function zipWith<T, R>(arr1: readonly T[], combine: (item: T, index: number) => 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, index: number) => R} combine - The combiner function that takes corresponding elements from each array, their index, 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 */
40declare function zipWith<T, U, R>(arr1: readonly T[], arr2: readonly U[], combine: (item1: T, item2: U, index: number) => 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, index: number) => R} combine - The combiner function that takes corresponding elements from each array, their index, 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 */
54declare function zipWith<T, U, V, R>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[], combine: (item1: T, item2: U, item3: V, index: number) => 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, index: number) => R} combine - The combiner function that takes corresponding elements from each array, their index, 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 */
70declare 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, index: number) => R): R[];
71
72export { zipWith };
Note: See TracBrowser for help on using the repository browser.