Skip to main content

Tuple

Helper functions that have to do with TypeScript tuples.

Functions

tupleEntries()

function tupleEntries<T>(tuple): Generator<TupleEntry<T>>

Helper function to get the entries (i.e. indexes and values) of a tuple in a type-safe way.

This is useful because the vanilla Array.entries method will always have the keys be of type number.

Type Parameters

Type Parameter
T extends readonly unknown[]

Parameters

ParameterType
tupleT

Returns

Generator<TupleEntry<T>>

Defined in

functions/tuple.ts:21


tupleKeys()

function tupleKeys<T>(tuple): Generator<TupleKey<T>>

Helper function to get the keys (i.e. indexes) of a tuple in a type-safe way.

This is useful because the vanilla Array.keys method will always have the keys be of type number.

Type Parameters

Type Parameter
T extends readonly unknown[]

Parameters

ParameterType
tupleT

Returns

Generator<TupleKey<T>>

Defined in

functions/tuple.ts:33