Hyperlinkv0.8.0-beta.28

Array

Array.isReadonlyArrayNonEmptyconsteffect/Array.ts:892
<A>(self: ReadonlyArray<A>): self is NonEmptyReadonlyArray<A>

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
Source effect/Array.ts:8922 lines
export const isReadonlyArrayNonEmpty: <A>(self: ReadonlyArray<A>) => self is NonEmptyReadonlyArray<A> =
  internalArray.isArrayNonEmpty
Referenced by 34 symbols