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

Function parsePrimitive

packages/effect/src/internal/configProvider.ts:622–643  ·  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

620}
621
622const parsePrimitive = <A>(
623 text: string,
624 path: ReadonlyArray<string>,
625 primitive: Config.Config.Primitive<A>,
626 delimiter: string,
627 split: boolean
628): Effect.Effect<Array<A>, ConfigError.ConfigError> => {
629 if (!split) {
630 return pipe(
631 primitive.parse(text),
632 core.mapBoth({
633 onFailure: configError.prefixed(path),
634 onSuccess: Arr.of
635 })
636 )
637 }
638 return pipe(
639 splitPathString(text, delimiter),
640 core.forEachSequential((char) => primitive.parse(char.trim())),
641 core.mapError(configError.prefixed(path))
642 )
643}
644
645const transpose = <A>(array: ReadonlyArray<ReadonlyArray<A>>): Array<Array<A>> => {
646 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