Hyperlinkv0.8.0-beta.28

Tuple

Tuple.isTupleOfAtLeastconsteffect/Predicate.ts:407
<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>

Checks whether a readonly array has at least n elements.

When to use

Use when you need a Predicate guard for tuple-like minimum length that narrows ReadonlyArray<T> to TupleOfAtLeast<N, T>.

Details

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

Example (Checking minimum length)

import { Predicate } from "effect"

const hasAtLeast2 = Predicate.isTupleOfAtLeast(2)

console.log(hasAtLeast2([1, 2, 3]))
export 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>
} = dual(2, <T, N extends number>(self: ReadonlyArray<T>, n: N): self is TupleOfAtLeast<N, T> => self.length >= n)
Referenced by 1 symbols