es-next-tools
Version:
A comprehensive utility library for JavaScript and TypeScript that provides a wide range of functions for common programming tasks, including mathematical operations, date manipulations, array and object handling, string utilities, and more.
13 lines (12 loc) • 482 B
TypeScript
/**
* Combines two arrays into an array of pairs.
* @param {T[]} array - The first array.
* @param {U[]} otherArray - The second array to zip with the first array.
* @returns {[T, U][]} An array of pairs combining elements from both arrays.
* @template T, U
* @example
* const arr1 = [1, 2, 3];
* const arr2 = ['a', 'b', 'c'];
* const zipped = zip(arr1, arr2); // [[1, 'a'], [2, 'b'], [3, 'c']]
*/
export declare function zip<T, U>(array: T[], otherArray: U[]): [T, U][];