Package: effect
Module: Stream
Creates a stream by peeling off the “layers” of a value of type S.
Example
import { Effect, Option, Stream } from "effect"
const stream = Stream.unfold(1, (n) => Option.some([n, n + 1]))
Effect.runPromise(Stream.runCollect(stream.pipe(Stream.take(5)))).then(console.log)
// { _id: 'Chunk', values: [ 1, 2, 3, 4, 5 ] }
Signature
declare const unfold: <S, A>(s: S, f: (s: S) => Option.Option<readonly [A, S]>) => Stream<A>
Since v2.0.0