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

Function transformSingle

packages/effect/src/cli/Param.ts:2392–2413  ·  view source on GitHub ↗
(
  param: Param<Kind, A>,
  f: <X>(single: Single<Kind, X>) => Single<Kind, X>
)

Source from the content-addressed store, hash-verified

2390 * This is used internally by combinators like `withAlias` to traverse the param tree.
2391 */
2392const transformSingle = <Kind extends ParamKind, A>(
2393 param: Param<Kind, A>,
2394 f: <X>(single: Single<Kind, X>) => Single<Kind, X>
2395): Param<Kind, A> => {
2396 return matchParam(param, {
2397 Single: (single) => f(single),
2398 Map: (mapped) => map(transformSingle(mapped.param, f), mapped.f),
2399 Transform: (mapped) =>
2400 transform(
2401 transformSingle(mapped.param, f),
2402 mapped.f,
2403 mapped.alternatives.map((alternative) => () => transformSingle(alternative(), f)),
2404 mapped.fallback
2405 ),
2406 Optional: (p) => optional(transformSingle(p.param, f)) as Param<Kind, A>,
2407 Variadic: (p) =>
2408 variadic(transformSingle(p.param, f), {
2409 min: Option.getOrUndefined(p.min),
2410 max: Option.getOrUndefined(p.max)
2411 }) as Param<Kind, A>
2412 })
2413}
2414
2415/**
2416 * Extracts all Single params from a potentially nested param structure.

Callers 3

Param.tsFile · 0.85
withHiddenFunction · 0.85
withoutNegationFunction · 0.85

Calls 7

matchParamFunction · 0.85
variadicFunction · 0.85
transformFunction · 0.70
optionalFunction · 0.70
fFunction · 0.50
mapFunction · 0.50
mapMethod · 0.45

Tested by

no test coverage detected