effect-io-ai

Package: effect
Module: Stream

Stream.unwrap

Creates a stream produced from an Effect.

Example (Unwrapping a stream effect)

import { Console, Effect, Stream } from "effect"

const effect = Effect.succeed(Stream.make(1, 2, 3))

const stream = Stream.unwrap(effect)

const program = Effect.gen(function*() {
  const chunk = yield* Stream.runCollect(stream)
  yield* Console.log(chunk)
})
// [1, 2, 3]

Signature

declare const unwrap: <A, E2, R2, E, R>(effect: Effect.Effect<Stream<A, E2, R2>, E, R>) => Stream<A, E | E2, R2 | Exclude<R, Scope.Scope>>

Source

Since v2.0.0