Skip to main content
Module

x/silicon/deps.ts>isUniformTupleOf

Deno module to generate images from source code using Aloxaf/silicon.
Latest
function isUniformTupleOf
import { isUniformTupleOf } from "https://deno.land/x/silicon@v1.0.0/deps.ts";

Return a type predicate function that returns true if the type of x is UniformTupleOf<T>.

import is from "./is.ts";

const a: unknown = [0, 1, 2, 3, 4];
if (is.UniformTupleOf(5)(a)) {
 // a is narrowed to [unknown, unknown, unknown, unknown, unknown]
 const _: readonly [unknown, unknown, unknown, unknown, unknown] = a;
}

if (is.UniformTupleOf(5, is.Number)(a)) {
 // a is narrowed to [number, number, number, number, number]
 const _: readonly [number, number, number, number, number] = a;
}

Type Parameters

T
N extends number

Parameters

n: N
optional
pred: Predicate<T> = [UNSUPPORTED]