effect-io-ai

Package: effect
Module: Predicate

Predicate.isTupleOf

Checks whether a readonly array has exactly n elements.

When to use

Use when you need a Predicate guard for exact tuple length that narrows ReadonlyArray<T> to TupleOf<N, T>.

Details

This only checks length, not element types, and returns a refinement on the array type.

Example (Checking exact length)

import { Predicate } from "effect"

const isPair = Predicate.isTupleOf(2)

console.log(isPair([1, 2]))

See

Signature

declare const isTupleOf: { <N extends number>(n: N): <T>(self: ReadonlyArray<T>) => self is TupleOf<N, T>; <T, N extends number>(self: ReadonlyArray<T>, n: N): self is TupleOf<N, T>; }

Source

Since v3.3.0