effect-io-ai

Package: effect
Module: Array

Array.isReadonlyArrayNonEmpty

Checks whether a ReadonlyArray is non-empty, narrowing the type to NonEmptyReadonlyArray.

When to use

Use when you need to prove a readonly array has at least one element without requiring mutable array methods afterward.

Example (Checking for a non-empty readonly array)

import { Array } from "effect"

console.log(Array.isReadonlyArrayNonEmpty([])) // false
console.log(Array.isReadonlyArrayNonEmpty([1, 2, 3])) // true

See

Signature

declare const isReadonlyArrayNonEmpty: <A>(self: ReadonlyArray<A>) => self is NonEmptyReadonlyArray<A>

Source

Since v4.0.0