ts-type-forge
    Preparing search index...

    Type Alias Zip<A, B>

    Zip: ZipSteps<ZipStep<A>, ZipStep<B>>

    Creates pairs of elements from two readonly arrays or tuples A and B. Zipping stops at the shorter input, so the result has as many required pairs as both inputs are sure to have elements, then optional pairs up to the shorter input's greatest length, and ends in an unsized array of pairs only when both inputs are unsized. An optional element ([A, B?]) is a pair that may be missing, and an element after a rest ([...A[], B]) counts toward the length, with the array's element type, since which element sits at a position is not known. The result never claims a pair that may be missing.

    Type Parameters

    • A extends readonly unknown[]

      The first readonly array or tuple.

    • B extends readonly unknown[]

      The second readonly array or tuple.

    A readonly array/tuple of pairs readonly [A[i], B[i]].

    type Z1 = List.Zip<[1, 2], ['a', 'b']>; // readonly [[1, 'a'], [2, 'b']]
    type Z2 = List.Zip<[1, 2, 3], ['a', 'b']>; // readonly [[1, 'a'], [2, 'b']]
    type Z3 = List.Zip<readonly number[], readonly string[]>; // readonly (readonly [number, string])[]
    type Z4 = List.Zip<[1, 2], readonly string[]>; // readonly [[1, string]?, [2, string]?]
    type Z5 = List.Zip<readonly number[], ['a', 'b']>; // readonly [[number, 'a']?, [number, 'b']?]
    type Z6 = List.Zip<[1, 2], readonly [string, ...string[]]>; // readonly [[1, string], [2, string]?]