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

Function run

packages/effect/src/encoding/Zip.ts:426–437  ·  view source on GitHub ↗
(f: () => A | undefined | typeof NeedInput, end: () => D)

Source from the content-addressed store, hash-verified

424 lock.withPermit(Effect.suspend(() => pulls === seen ? pullUpstream : Effect.void))
425
426 const run = <A, D>(f: () => A | undefined | typeof NeedInput, end: () => D): Pull.Pull<A, ZipError | IE, D> =>
427 Effect.suspend(function loop(): Pull.Pull<A, ZipError | IE, D> {
428 const seen = pulls
429 let result: A | undefined | typeof NeedInput
430 try {
431 result = f()
432 } catch (error) {
433 return isZipError(error) ? Effect.fail(error) : Effect.die(error)
434 }
435 if (result === NeedInput) return Effect.flatMap(pullInput(seen), loop)
436 return result === undefined ? Cause.done(end()) : Effect.succeed(result)
437 })
438
439 const body = (id: number): Stream.Stream<Uint8Array, ZipError | IE> =>
440 Stream.fromPull(Effect.succeed(run(() => decoder.read(id), () => undefined)))

Callers 2

bodyFunction · 0.70
decodeFunction · 0.70

Calls 7

isZipErrorFunction · 0.85
pullInputFunction · 0.70
failMethod · 0.65
fFunction · 0.50
endFunction · 0.50
doneMethod · 0.45
succeedMethod · 0.45

Tested by

no test coverage detected