Deprecated
Use is.ReadonlyOf(is.UniformTupleOf(...))
instead.
To enhance performance, users are advised to cache the return value of this function and mitigate the creation cost.
import { is } from "@core/unknownutil";
const isMyType = is.ReadonlyUniformTupleOf(5);
const a: unknown = [0, 1, 2, 3, 4];
if (isMyType(a)) {
// a is narrowed to readonly [unknown, unknown, unknown, unknown, unknown]
const _: readonly [unknown, unknown, unknown, unknown, unknown] = a;
}
With predicate function:
import { is } from "@core/unknownutil";
const isMyType = is.ReadonlyUniformTupleOf(5, is.Number);
const a: unknown = [0, 1, 2, 3, 4];
if (isMyType(a)) {
// a is narrowed to readonly [number, number, number, number, number]
const _: readonly [number, number, number, number, number] = a;
}
import { isReadonlyUniformTupleOf } from "https://deno.land/x/unknownutil@v3.18.1/mod.ts";
Return a type predicate function that returns true
if the type of x
is Readonly<UniformTupleOf<T>>
.
Returns
Predicate<Readonly<UniformTupleOf<T, N>>> & WithMetadata<IsReadonlyOfMetadata>