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

Function loop

packages/effect/src/Stream.ts:2996–3019  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2994 return loop()
2995 })
2996 function loop(): Pull.Pull<Arr.NonEmptyReadonlyArray<A>, E> {
2997 while (true) {
2998 if (iterator !== undefined) {
2999 const buffer: Array<A> = []
3000 while (buffer.length < DefaultChunkSize) {
3001 const result = iterator.next()
3002 if (result.done) {
3003 iterator = undefined
3004 break
3005 }
3006 buffer.push(result.value)
3007 }
3008 if (Arr.isArrayNonEmpty(buffer)) return Effect.succeed(buffer)
3009 }
3010 if (chunk === undefined) return refill
3011 const iterable = chunk[index++]
3012 if (index === chunk.length) chunk = undefined
3013 if (Array.isArray(iterable)) {
3014 if (Arr.isArrayNonEmpty(iterable)) return Effect.succeed(iterable)
3015 } else {
3016 iterator = iterable[Symbol.iterator]()
3017 }
3018 }
3019 }
3020 return Effect.as(
3021 Scope.addFinalizer(scope, Effect.sync(() => iterator?.return?.())),
3022 Effect.suspend(loop)

Callers 5

takeAllFunction · 0.70
releaseFunction · 0.70
paginateFunction · 0.70
flattenIterableFunction · 0.70
Stream.tsFile · 0.70

Calls 8

unwrapFunction · 0.70
stepFunction · 0.70
failFunction · 0.70
nextMethod · 0.65
pushMethod · 0.65
succeedMethod · 0.45
syncMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected