Package: effect
Module: Tuple
Checks whether an array has at least N elements, narrowing the type to a
tuple with a minimum length.
When to use
Use to guard that an array has at least the tuple length expected at runtime.
Details
This is a re-export of Predicate.isTupleOfAtLeast. It narrows the type to
TupleOfAtLeast<N, T> in the truthy branch.
Gotchas
This only checks .length; it does not validate element types.
Example (Checking minimum length)
import { Tuple } from "effect"
const arr: Array<number> = [1, 2, 3, 4]
if (Tuple.isTupleOfAtLeast(arr, 3)) {
console.log(arr)
// ^? [number, number, number, ...number[]]
}
See
isTupleOf – check for an exact lengthSignature
declare const isTupleOfAtLeast: { <N extends number>(n: N): <T>(self: ReadonlyArray<T>) => self is TupleOfAtLeast<N, T>; <T, N extends number>(self: ReadonlyArray<T>, n: N): self is TupleOfAtLeast<N, T>; }
Since v3.3.0