effect-io-ai

Package: effect
Module: Stream

Stream.forever

Repeats this stream forever.

Example (Repeating a stream forever)

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

const stream = Stream.make("A", "B").pipe(
  Stream.forever,
  Stream.take(5)
)

const program = Effect.gen(function*() {
  const output = yield* Stream.runCollect(stream)
  yield* Console.log(output)
})

Effect.runPromise(program)
// Output: [ "A", "B", "A", "B", "A" ]

Signature

declare const forever: <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R>

Source

Since v2.0.0