Hyperlinkv0.8.0-beta.28

Stream

Stream.toPullconsteffect/Stream.ts:11037
<A, E, R>(self: Stream<A, E, R>): Effect.Effect<
  Pull.Pull<Arr.NonEmptyReadonlyArray<A>, E>,
  never,
  R | Scope.Scope
>

Returns a scoped pull for manually consuming the stream's output chunks.

Details

The pull fails with Cause.Done when the stream ends and with the stream error on failure.

Example (Creating a scoped pull)

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

const stream = Stream.make(1, 2, 3)

const program = Effect.scoped(
  Effect.gen(function*() {
    const pull = yield* Stream.toPull(stream)
    const chunk = yield* pull
    yield* Console.log(chunk)
  })
)

Effect.runPromise(program)
// [1, 2, 3]
destructors
export const toPull = <A, E, R>(
  self: Stream<A, E, R>
): Effect.Effect<Pull.Pull<Arr.NonEmptyReadonlyArray<A>, E>, never, R | Scope.Scope> => Channel.toPull(self.channel)