Skip to main content
Module

x/fun/decoder.ts>tuple

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
function tuple
import { tuple } from "https://deno.land/x/fun@v2.0.0/decoder.ts";

A decoder over a heterogenous tuple. This tuple can have different values for each tuple element, but is constrained to a specific size and order.

Examples

Example 1

import * as D from "./decoder.ts";

const tuple = D.tuple(D.string, D.number);

const result1 = tuple([]); // Left(DecodeError)
const result2 = tuple([3, "Hello"]); // Left(DecodeError)
const result3 = tuple(["Brandon", 37]); // Right(["Brandon", 37])

Parameters

...items: [K in keyof A]: Decoder<unknown, A[K]>

Returns

Decoder<unknown, readonly [K in keyof A]: A[K]>