UNPKG

@naverpay/hidash

Version:

improved lodash

25 lines (22 loc) 1.46 kB
import { List } from './internal/types.mjs'; /** * @description * Combines multiple arrays into a single array of grouped elements, where each group contains the elements at the same index from each input array. * If the input arrays have different lengths, `undefined` is used for missing values. * * * @param {...List<T>} arrays The arrays to process. * @returns {(T | undefined)[][]} An array of grouped elements. * * @example * zip([1, 2], ['a', 'b']) // [[1, 'a'], [2, 'b']] * zip([1, 2], ['a']) // [[1, 'a'], [2, undefined]] * zip([1, 2], null, [true, false, true]) // [[1, undefined, true], [2, undefined, false], [undefined, undefined, true]] * zip() // [] */ declare function zip<T1, T2>(arrays1: List<T1>, arrays2: List<T2>): [T1 | undefined, T2 | undefined][]; declare function zip<T1, T2, T3>(arrays1: List<T1>, arrays2: List<T2>, arrays3: List<T3>): [T1 | undefined, T2 | undefined, T3 | undefined][]; declare function zip<T1, T2, T3, T4>(arrays1: List<T1>, arrays2: List<T2>, arrays3: List<T3>, arrays4: List<T4>): [T1 | undefined, T2 | undefined, T3 | undefined, T4 | undefined][]; declare function zip<T1, T2, T3, T4, T5>(arrays1: List<T1>, arrays2: List<T2>, arrays3: List<T3>, arrays4: List<T4>, arrays5: List<T5>): [T1 | undefined, T2 | undefined, T3 | undefined, T4 | undefined, T5 | undefined][]; declare function zip<T>(...arrays: (List<T> | null | undefined)[]): (T | undefined)[][]; export { zip as default, zip };