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

Function transform

packages/effect/src/cli/Param.ts:1206–1225  ·  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>>> = [],
  fallback?: Fallback | undefined
)

Source from the content-addressed store, hash-verified

1204})
1205
1206const transform = <Kind extends ParamKind, A, B>(
1207 self: Param<Kind, A>,
1208 f: (
1209 parse: Parse<A>,
1210 alternatives: ReadonlyArray<LazyArg<Parse<unknown>>>
1211 ) => Parse<B>,
1212 alternatives: ReadonlyArray<LazyArg<Param<Kind, unknown>>> = [],
1213 fallback?: Fallback | undefined
1214): Transform<Kind, A, B> => {
1215 const alternativeParsers = alternatives.map((alternative) => () => alternative().parse)
1216 return Object.assign(Object.create(Proto), {
1217 _tag: "Transform",
1218 kind: self.kind,
1219 param: self,
1220 alternatives,
1221 f,
1222 fallback,
1223 parse: f(self.parse, alternativeParsers)
1224 })
1225}
1226
1227/**
1228 * 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
applyTransformerFunction · 0.50

Calls 3

assignMethod · 0.80
fFunction · 0.50
mapMethod · 0.45

Tested by

no test coverage detected