MCPcopy Index your code
hub / github.com/Effect-TS/effect / unfoldChunkEffect

Function unfoldChunkEffect

packages/effect/src/internal/stream.ts:7419–7435  ·  view source on GitHub ↗
(
  s: S,
  f: (s: S) => Effect.Effect<Option.Option<readonly [Chunk.Chunk<A>, S]>, E, R>
)

Source from the content-addressed store, hash-verified

7417
7418/** @internal */
7419export const unfoldChunkEffect = <S, A, E, R>(
7420 s: S,
7421 f: (s: S) => Effect.Effect<Option.Option<readonly [Chunk.Chunk<A>, S]>, E, R>
7422): Stream.Stream<A, E, R> =>
7423 suspend(() => {
7424 const loop = (s: S): Channel.Channel<Chunk.Chunk<A>, unknown, E, unknown, unknown, unknown, R> =>
7425 channel.unwrap(
7426 Effect.map(
7427 f(s),
7428 Option.match({
7429 onNone: () => core.void,
7430 onSome: ([chunk, s]) => core.flatMap(core.write(chunk), () => loop(s))
7431 })
7432 )
7433 )
7434 return new StreamImpl(loop(s))
7435 })
7436
7437/** @internal */
7438export const unfoldEffect = <S, A, E, R>(

Callers 3

stream.tsFile · 0.85
repeatEffectChunkOptionFunction · 0.85
unfoldEffectFunction · 0.85

Calls 2

suspendFunction · 0.70
loopFunction · 0.70

Tested by

no test coverage detected