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

Function fileSchema

packages/effect/src/unstable/cli/Primitive.ts:804–819  ·  view source on GitHub ↗
(
  schema: Schema.ConstraintDecoder<A, Environment>,
  options?: FileSchemaOptions | undefined
)

Source from the content-addressed store, hash-verified

802 * @since 4.0.0
803 */
804export const fileSchema = <A>(
805 schema: Schema.ConstraintDecoder<A, Environment>,
806 options?: FileSchemaOptions | undefined
807): Primitive<A> => {
808 const decode = Schema.decodeUnknownEffect(schema)
809 return makePrimitive(
810 "FileSchema",
811 Effect.fnUntraced(function*(filePath) {
812 const content = yield* fileParse(options).parse(filePath)
813 return yield* Effect.mapError(
814 decode(content),
815 (error) => options?.errorFormatter?.(error.issue) ?? error.toString()
816 )
817 })
818 )
819}
820
821/**
822 * Parses a single `key=value` pair into a record object.

Callers

nothing calls this directly

Calls 5

makePrimitiveFunction · 0.70
fileParseFunction · 0.70
toStringMethod · 0.65
decodeFunction · 0.50
parseMethod · 0.45

Tested by

no test coverage detected