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

Function scoped

packages/effect/src/Micro.ts:3428–3432  ·  view source on GitHub ↗
(self: Micro<A, E, R>)

Source from the content-addressed store, hash-verified

3426 * @category resources & finalization
3427 */
3428export const scoped = <A, E, R>(self: Micro<A, E, R>): Micro<A, E, Exclude<R, MicroScope>> =>
3429 suspend(() => {
3430 const scope = new MicroScopeImpl()
3431 return onExit(provideService(self, MicroScope, scope), (exit) => scope.close(exit))
3432 })
3433
3434/**
3435 * Create a resource with a cleanup `Micro` effect, ensuring the cleanup is

Callers

nothing calls this directly

Calls 3

closeMethod · 0.95
suspendFunction · 0.70
onExitFunction · 0.70

Tested by

no test coverage detected