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

Function mapHandler

packages/effect/src/unstable/cli/Command.ts:1376–1382  ·  view source on GitHub ↗
(
  self: Command<Name, Input, ContextInput, E, R>,
  f: (handler: Effect.Effect<void, E | CliError.CliError, R | Environment>, input: Input) => Effect.Effect<void, E2, R2>
)

Source from the content-addressed store, hash-verified

1374
1375// Internal helper: transforms a command's handler while preserving other properties
1376const mapHandler = <Name extends string, Input, E, R, ContextInput, E2, R2>(
1377 self: Command<Name, Input, ContextInput, E, R>,
1378 f: (handler: Effect.Effect<void, E | CliError.CliError, R | Environment>, input: Input) => Effect.Effect<void, E2, R2>
1379): Command<Name, Input, ContextInput, E2, R2> => {
1380 const impl = toImpl(self)
1381 return makeCommand({ ...impl, handle: (input, path) => f(impl.handle(input, path), input) })
1382}
1383
1384/**
1385 * Provides the handler of a command with the services produced by a layer

Callers 1

Command.tsFile · 0.85

Calls 4

toImplFunction · 0.90
makeCommandFunction · 0.90
handleMethod · 0.65
fFunction · 0.50

Tested by

no test coverage detected