effect-io-ai

Package: effect
Module: Stream

Stream.fromIterable

Creates a new Stream from an iterable collection of values.

Details

Example (Creating a stream from an iterable)

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

const numbers = [1, 2, 3]

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

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

Signature

declare const fromIterable: <A>(iterable: Iterable<A>, options?: { readonly chunkSize?: number | undefined; }) => Stream<A>

Source

Since v2.0.0