ts-type-forge
    Preparing search index...

    Type Alias Zip<A, B>

    Zip: A extends NonEmptyArray<unknown>
        ? B extends NonEmptyArray<unknown>
            ? readonly [
                readonly [Tuple.Head<A>, Tuple.Head<B>],
                ...Tuple.Zip<Tuple.Tail<A>, Tuple.Tail<B>>,
            ]
            : readonly []
        : readonly []

    Creates pairs of elements from two readonly tuples A and B. The resulting tuple will have the length of the shorter input tuple.

    Type Parameters

    • A extends readonly unknown[]

      The first readonly tuple.

    • B extends readonly unknown[]

      The second readonly tuple.

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

    type Z1 = Tuple.Zip<[1, 2], ['a', 'b']>; // readonly [readonly [1, 'a'], readonly [2, 'b']]
    type Z2 = Tuple.Zip<[1, 2, 3], ['a', 'b']>; // readonly [readonly [1, 'a'], readonly [2, 'b']]
    type Z3 = Tuple.Zip<[1, 2], ['a', 'b', 'c']>; // readonly [readonly [1, 'a'], readonly [2, 'b']]
    type Z4 = Tuple.Zip<[], ['a']>; // readonly []