MCPcopy Index your code
hub / github.com/Effect-TS/effect / parsePrimitive

Function parsePrimitive

packages/effect/src/internal/configProvider.ts:601–622  ·  view source on GitHub ↗
(
  text: string,
  path: ReadonlyArray<string>,
  primitive: Config.Config.Primitive<A>,
  delimiter: string,
  split: boolean
)

Source from the content-addressed store, hash-verified

599}
600
601const parsePrimitive = <A>(
602 text: string,
603 path: ReadonlyArray<string>,
604 primitive: Config.Config.Primitive<A>,
605 delimiter: string,
606 split: boolean
607): Effect.Effect<Array<A>, ConfigError.ConfigError> => {
608 if (!split) {
609 return pipe(
610 primitive.parse(text),
611 core.mapBoth({
612 onFailure: configError.prefixed(path),
613 onSuccess: Arr.of
614 })
615 )
616 }
617 return pipe(
618 splitPathString(text, delimiter),
619 core.forEachSequential((char) => primitive.parse(char.trim())),
620 core.mapError(configError.prefixed(path))
621 )
622}
623
624const transpose = <A>(array: ReadonlyArray<ReadonlyArray<A>>): Array<Array<A>> => {
625 return Object.keys(array[0]).map((column) => array.map((row) => row[column as any]))

Callers 1

loadFunction · 0.85

Calls 3

splitPathStringFunction · 0.85
parseMethod · 0.80
pipeFunction · 0.70

Tested by

no test coverage detected