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

Function paginateChunk

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

Source from the content-addressed store, hash-verified

4495
4496/** @internal */
4497export const paginateChunk = <S, A>(
4498 s: S,
4499 f: (s: S) => readonly [Chunk.Chunk<A>, Option.Option<S>]
4500): Stream.Stream<A> => {
4501 const loop = (s: S): Channel.Channel<Chunk.Chunk<A>, unknown, never, unknown, unknown, unknown> => {
4502 const page = f(s)
4503 return Option.match(page[1], {
4504 onNone: () => channel.zipRight(core.write(page[0]), core.void),
4505 onSome: (s) => core.flatMap(core.write(page[0]), () => loop(s))
4506 })
4507 }
4508 return new StreamImpl(core.suspend(() => loop(s)))
4509}
4510
4511/** @internal */
4512export const paginateChunkEffect = <S, A, E, R>(

Callers 1

paginateFunction · 0.85

Calls 1

loopFunction · 0.70

Tested by

no test coverage detected