effect-io-ai

Package: effect
Module: Array

Array.ReadonlyArray.OrNonEmpty

Creates a non-empty array if either input is non-empty.

Example (Preserving non-emptiness from either input)

import type { Array } from "effect"

type Result = Array.ReadonlyArray.OrNonEmpty<
  readonly [number],
  ReadonlyArray<string>,
  number
>
// Result is NonEmptyArray<number>

Signature

type OrNonEmpty<S, T, A> = S extends NonEmptyReadonlyArray<any> ? NonEmptyArray<A>
    : T extends NonEmptyReadonlyArray<any> ? NonEmptyArray<A>
    : Array<A>

Source

Since v2.0.0