Skip to main content
Module

x/typestruct/mod.ts>tuple

Composable and checkable JavaScript (and TypeScript) data structure
Latest
function tuple
import { tuple } from "https://deno.land/x/typestruct@1.0.0-beta.5/mod.ts";

Create tuple struct. Tuple is array subtype. Ensure that the position and type of the elements match.

Examples

Example 1

import { is, tuple, and, array, number, string, object } from "https://deno.land/x/typestruct@$VERSION/mod.ts";
import { assertEquals } from "https://deno.land/std@$VERSION/testing/asserts.ts";

const Tuple = tuple([string(), number(), object()]);

assertEquals(is(Tuple, ["", 0, {}]), true);
assertEquals(is(and(array()).and(Tuple), [1, 2, 3] as unknown), true);

Type Parameters

F
R extends readonly Struct<unknown>[]

Parameters

structs: [Struct<unknown, F>, ...R]
optional
message: string

Custom issue message.

Returns

Struct<readonly unknown[], [F, ...R]>