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
Parameter | Type |
---|---|
tuple | T |
Returns
Generator
<TupleEntry
<T
>>
Defined in
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
Parameter | Type |
---|---|
tuple | T |
Returns
Generator
<TupleKey
<T
>>