@arrows/array
Version:
Functional tools for JS arrays
25 lines (24 loc) • 912 B
TypeScript
declare type Pairs<T, V> = [T | undefined, V | undefined][];
declare type _ZipAll_ = <T, V>(otherArr: V[], arr: T[]) => Pairs<T, V>;
declare type _ZipAll2_ = <T, V>(otherArr: V[]) => (arr: T[]) => Pairs<T, V>;
declare type ZipAll_ = _ZipAll_ & _ZipAll2_;
declare type _Zip_ = <T, V>(otherArr: V[], arr: T[]) => [T, V][];
declare type _Zip2_ = <T, V>(otherArr: V[]) => (arr: T[]) => [T, V][];
declare type CurriedZip_ = _Zip_ & _Zip2_;
declare type Zip_ = CurriedZip_ & {
all: ZipAll_;
};
/**
* Zips two arrays creating an array of pairs
* containing values on corresponding indexes.
* Zips until the length of the shorter array is reached.
*
* @param otherArr Array that you want to zip with initial array
* @param arr Initial array
* @returns New, zipped array
*
* @method all Zips until the length of the longer array is reached
*/
declare const zip_: Zip_;
export { zip_ };
export default zip_;