ts-type-forge
    Preparing search index...

    Type Alias Partition<N, T>

    Partition: PartitionImpl<N, T, readonly [], readonly []>

    Partitions a readonly tuple T into sub-tuples of length N. The last sub-tuple may have fewer than N elements if the length of T is not divisible by N.

    Type Parameters

    • N extends number

      The desired size of each partition (must be a positive integer literal).

    • T extends readonly unknown[]

      The readonly tuple type to partition.

    A readonly tuple where each element is a sub-tuple of length up to N.

    type P1 = Tuple.Partition<2, [1, 2, 3, 4, 5]>; // readonly [readonly [1, 2], readonly [3, 4], readonly [5]]
    type P2 = Tuple.Partition<3, [1, 2, 3, 4, 5, 6]>; // readonly [readonly [1, 2, 3], readonly [4, 5, 6]]
    type P3 = Tuple.Partition<1, [1, 2]>; // readonly [readonly [1], readonly [2]]
    type P4 = Tuple.Partition<5, [1, 2]>; // readonly [readonly [1, 2]]