Skip to main content
Module

x/fun/refinement.ts>isArrayN

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

Creates an instance Refinement<unknown, Array<unknown> & { length: N }> where N is a number.

Examples

Example 1

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

const isTwoTuple = R.isArrayN(2);

const result1 = isTwoTuple(null); // false
const result2 = isTwoTuple([]); // false
const result3 = isTwoTuple([1, 2]);
// true, a variable is now typed as Array<unknown> & { length: 2 }

Type Parameters

N extends number

Returns

Refinement<unknown, Array<unknown> & { length: N; }>