UNPKG

@naverpay/hidash

Version:

improved lodash

19 lines (16 loc) 751 B
import { List } from './internal/types.js'; /** * @description * Transposes an array of arrays (e.g., the output of `zip`) so that the first array contains the first element of each input array, the second array contains the second element, and so on. * If the input arrays have different lengths, missing values are left as `undefined`. * * @param {T[][] | List<List<T>> | null | undefined} array The array of arrays to transpose. * @returns {T[][]} The transposed array. * * @example * unzip([[1, 2], ['a', 'b']]) // [[1, 'a'], [2, 'b']] * unzip([[1, 2], ['a']]) // [[1, 'a'], [2, undefined]] * unzip(null) // [] */ declare function unzip<T>(array: T[][] | List<List<T>> | null | undefined): T[][]; export { unzip as default, unzip };