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

Function paginateChunkEffect

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

Source from the content-addressed store, hash-verified

4510
4511/** @internal */
4512export const paginateChunkEffect = <S, A, E, R>(
4513 s: S,
4514 f: (s: S) => Effect.Effect<readonly [Chunk.Chunk<A>, Option.Option<S>], E, R>
4515): Stream.Stream<A, E, R> => {
4516 const loop = (s: S): Channel.Channel<Chunk.Chunk<A>, unknown, E, unknown, unknown, unknown, R> =>
4517 channel.unwrap(
4518 Effect.map(f(s), ([chunk, option]) =>
4519 Option.match(option, {
4520 onNone: () => channel.zipRight(core.write(chunk), core.void),
4521 onSome: (s) => core.flatMap(core.write(chunk), () => loop(s))
4522 }))
4523 )
4524 return new StreamImpl(core.suspend(() => loop(s)))
4525}
4526
4527/** @internal */
4528export const paginateEffect = <S, A, E, R>(

Callers 1

paginateEffectFunction · 0.85

Calls 1

loopFunction · 0.70

Tested by

no test coverage detected