Skip to content

toTuple

The toTuple() method converts a value into a tuple by applying a series of transformation functions.

Interactive example

Syntax

Classic signature

typescript
function toTuple<
	GenericInput extends unknown, 
	GenericShapeTuple extends ShapeTuple<GenericInput>
>(
	input: GenericInput, 
	shapeObject: ShapeTuple<GenericInput> & GenericShapeTuple
): ComputesResult<GenericShapeTuple>

Curried signature

typescript
function toTuple<
	GenericInput extends unknown, 
	GenericShapeTuple extends ShapeTuple<NoInfer<GenericInput>>
>(
	shapeObject: ShapeTuple<NoInfer<GenericInput>> & GenericShapeTuple
): (input: GenericInput) => ComputesResult<NoInfer<GenericShapeTuple>>

Parameters

  • input: The input value to transform into a tuple.
  • shapeObject: An array of functions to apply to the input to build the tuple.

Return value

A tuple containing the results of each function applied to the input, with strict typing.

See also

  • from - Creates an array from an iterable

Sources

Released under the MIT license.