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

Function runtimePromise

packages/effect/src/FiberSet.ts:675–704  ·  view source on GitHub ↗
(self: FiberSet<A, E>)

Source from the content-addressed store, hash-verified

673 * @since 3.13.0
674 */
675export const runtimePromise = <A, E>(self: FiberSet<A, E>): <R = never>() => Effect.Effect<
676 <XE extends E, XA extends A>(
677 effect: Effect.Effect<XA, XE, R>,
678 options?:
679 | Effect.RunOptions & { readonly propagateInterruption?: boolean | undefined }
680 | undefined
681 ) => Promise<XA>,
682 never,
683 R
684> =>
685<R>() =>
686 Effect.map(
687 runtime(self)<R>(),
688 (runFork) =>
689 <XE extends E, XA extends A>(
690 effect: Effect.Effect<XA, XE, R>,
691 options?:
692 | Effect.RunOptions & { readonly propagateInterruption?: boolean | undefined }
693 | undefined
694 ): Promise<XA> =>
695 new Promise((resolve, reject) =>
696 runFork(effect, options).addObserver((exit) => {
697 if (Exit.isSuccess(exit)) {
698 resolve(exit.value)
699 } else {
700 reject(Cause.squash(exit.cause))
701 }
702 })
703 )
704 )
705
706/**
707 * Gets the number of fibers currently in the FiberSet.

Callers 1

makeRuntimePromiseFunction · 0.70

Calls 6

runForkFunction · 0.85
addObserverMethod · 0.80
runtimeFunction · 0.70
resolveFunction · 0.70
rejectFunction · 0.50
mapMethod · 0.45

Tested by

no test coverage detected