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

Function run

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

Source from the content-addressed store, hash-verified

383 lock.withPermit(Effect.suspend(() => pulls === seen ? pullUpstream : Effect.void))
384
385 const run = <A, D>(f: () => A | undefined | typeof NeedInput, end: () => D): Pull.Pull<A, TarError | IE, D> =>
386 Effect.suspend(function loop(): Pull.Pull<A, TarError | IE, D> {
387 const seen = pulls
388 let result: A | undefined | typeof NeedInput
389 try {
390 result = f()
391 } catch (error) {
392 return isTarError(error) ? Effect.fail(error) : Effect.die(error)
393 }
394 if (result === NeedInput) return Effect.flatMap(pullInput(seen), loop)
395 return result === undefined ? Cause.done(end()) : Effect.succeed(result)
396 })
397
398 const body = (id: number): Stream.Stream<Uint8Array, TarError | IE> =>
399 Stream.fromPull(Effect.succeed(run(() => decoder.read(id), () => undefined)))

Callers 4

bodyFunction · 0.70
decodeFunction · 0.70
emitFunction · 0.70
emitFunction · 0.70

Calls 7

isTarErrorFunction · 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