MCPcopy Create free account
hub / github.com/Effect-TS/effect / loop

Function loop

packages/effect/src/internal/stream.ts:2261–2277  ·  view source on GitHub ↗
(r: number)

Source from the content-addressed store, hash-verified

2259 <A, E, R>(self: Stream.Stream<A, E, R>, n: number) => Stream.Stream<A, E, R>
2260>(2, <A, E, R>(self: Stream.Stream<A, E, R>, n: number): Stream.Stream<A, E, R> => {
2261 const loop = (r: number): Channel.Channel<Chunk.Chunk<A>, Chunk.Chunk<A>, never, never, unknown, unknown> =>
2262 core.readWith({
2263 onInput: (input: Chunk.Chunk<A>) => {
2264 const dropped = pipe(input, Chunk.drop(r))
2265 const leftover = Math.max(0, r - input.length)
2266 const more = Chunk.isEmpty(input) || leftover > 0
2267 if (more) {
2268 return loop(leftover)
2269 }
2270 return pipe(
2271 core.write(dropped),
2272 channel.zipRight(channel.identityChannel<Chunk.Chunk<A>, never, unknown>())
2273 )
2274 },
2275 onFailure: core.fail,
2276 onDone: () => core.void
2277 })
2278 return new StreamImpl(pipe(toChannel(self), channel.pipeToOrFail(loop(n))))
2279})
2280

Callers 10

releaseFunction · 0.70
stream.tsFile · 0.70
fromIteratorSucceedFunction · 0.70
paginateChunkFunction · 0.70
paginateChunkEffectFunction · 0.70
splitFunction · 0.70
throttleEnforceEffectFunction · 0.70
throttleShapeEffectFunction · 0.70
unfoldChunkFunction · 0.70
unfoldChunkEffectFunction · 0.70

Calls 15

syncMethod · 0.80
fromEffectMethod · 0.80
pipeFunction · 0.70
splitFunction · 0.70
isEmptyMethod · 0.65
writeMethod · 0.65
nextMethod · 0.65
mapMethod · 0.65
ofMethod · 0.65
makeMethod · 0.65
takeMethod · 0.65
zipMethod · 0.65

Tested by

no test coverage detected