effect-io-ai

Package: effect
Module: Chunk

Chunk.Chunk.AndNonEmpty

Creates a non-empty Chunk only if both inputs are non-empty.

Example (Requiring non-emptiness from both inputs)

import type { Chunk } from "effect"

declare const emptyChunk: Chunk.Chunk<number>
declare const nonEmptyChunk: Chunk.NonEmptyChunk<number>

type Result1 = Chunk.Chunk.AndNonEmpty<
  typeof emptyChunk,
  typeof emptyChunk,
  string
> // Chunk.Chunk<string>
type Result2 = Chunk.Chunk.AndNonEmpty<
  typeof emptyChunk,
  typeof nonEmptyChunk,
  string
> // Chunk.Chunk<string>
type Result3 = Chunk.Chunk.AndNonEmpty<
  typeof nonEmptyChunk,
  typeof nonEmptyChunk,
  string
> // Chunk.NonEmptyChunk<string>

Signature

type AndNonEmpty<S, T, A> = S extends NonEmptyChunk<any> ?
    T extends NonEmptyChunk<any> ? NonEmptyChunk<A>
    : Chunk<A> :
    Chunk<A>

Source

Since v2.0.0