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

Function transform

packages/effect/src/unstable/cli/Param.ts:1066–1083  ·  view source on GitHub ↗
(
  self: Param<Kind, A>,
  f: (
    parse: Parse<A>,
    alternatives: ReadonlyArray<LazyArg<Parse<unknown>>>
  ) => Parse<B>,
  alternatives: ReadonlyArray<LazyArg<Param<Kind, unknown>>> = []
)

Source from the content-addressed store, hash-verified

1064})
1065
1066const transform = <Kind extends ParamKind, A, B>(
1067 self: Param<Kind, A>,
1068 f: (
1069 parse: Parse<A>,
1070 alternatives: ReadonlyArray<LazyArg<Parse<unknown>>>
1071 ) => Parse<B>,
1072 alternatives: ReadonlyArray<LazyArg<Param<Kind, unknown>>> = []
1073): Transform<Kind, A, B> => {
1074 const alternativeParsers = alternatives.map((alternative) => () => alternative().parse)
1075 return Object.assign(Object.create(Proto), {
1076 _tag: "Transform",
1077 kind: self.kind,
1078 param: self,
1079 alternatives,
1080 f,
1081 parse: f(self.parse, alternativeParsers)
1082 })
1083}
1084
1085/**
1086 * Transforms the parsed value of an option using an effectful mapping function.

Callers 5

Param.tsFile · 0.70
transformSingleFunction · 0.70
Atom.tsFile · 0.50
makeCompilerSqliteFunction · 0.50
withStatementFunction · 0.50

Calls 3

assignMethod · 0.80
fFunction · 0.50
mapMethod · 0.45

Tested by

no test coverage detected