Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/fun/mod.ts>refinement.tuple

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

Create a Refinement from an array of refinements, where each index of a type much match the originated refinement type.

Examples

Example 1

import * as R from "./refinement.ts";

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

const result1 = tuple(null); // false
const result2 = tuple([]); // false
const result3 = tuple(["Hello", 1]); // false
const result4 = tuple([1, "Hello"]);
// true, variable has type [number, string]
const result5 = tuple([1, "Hello", "Goodbye"]); // false

Type Parameters

A extends any[]

Parameters

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

Returns

Refinement<unknown, [K in keyof A]: A[K]>