Type Alias Columnify<N, S>

Columnify<N, S>: Or<IfExtends<N, 1>, IsLessThan1<N>> extends true
    ? readonly [S]
    : IsWideNumber<N> extends true
        ? ChunksFrom<S>
        : S["length"] extends 0
            ? FillWithChunks<N, readonly []>
            : IsNonEmptyArray<S> extends true
                ? ProcessColumnify<N, S>
                : FillWithChunks<N, readonly [], ReadonlyArray<S[number]>>

Converts a tuple type into a tuple of tuples, where each tuple is a column of the original tuple.

Type Parameters

  • N extends number
  • S extends ReadonlyArray<unknown>
type T0 = Columnify<2, [1, 2, 3, 4, 5, 6]>;
// ^ = type T0 = [[1, 3, 5], [2, 4, 6]]