ts-type-forge
    Preparing search index...

    Type Alias Zip<A, B>

    Zip: A extends readonly []
        ? readonly []
        : B extends readonly []
            ? readonly []
            : A extends NonEmptyArray<unknown>
                ? B extends NonEmptyArray<unknown>
                    ? readonly [
                        readonly [List.Head<A>, List.Head<B>],
                        ...List.Zip<List.Tail<A>, List.Tail<B>>,
                    ]
                    : readonly [
                        readonly [List.Head<A>, B[number]],
                        ...List.Zip<List.Tail<A>, List.Tail<B>>,
                    ]
                : B extends NonEmptyArray<unknown>
                    ? readonly [
                        readonly [A[number], List.Head<B>],
                        ...List.Zip<List.Tail<A>, List.Tail<B>>,
                    ]
                    : readonly (readonly [A[number], B[number]])[]

    Creates pairs of elements from two readonly arrays or tuples A and B. If the arrays/tuples have different lengths, the resulting type reflects pairing up to the shortest length, potentially using the general element type for the longer array if one is a general array.

    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']]