effect-io-ai

Package: effect
Module: Stream

Stream.fromArray

Creates a stream from an array of values.

Example (Creating a stream from an array of values)

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

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

Effect.runPromise(program)
// Output: [ 1, 2, 3 ]

Signature

declare const fromArray: <A>(array: ReadonlyArray<A>) => Stream<A>

Source

Since v4.0.0