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

Function parser

packages/effect/src/encoding/SchemaBinary.ts:343–363  ·  view source on GitHub ↗
(
  schema: S,
  options?: SchemaAST.ParseOptions & Options & StreamOptions & { readonly maxFrameSize?: number | undefined }
)

Source from the content-addressed store, hash-verified

341 * @since 4.0.0
342 */
343export function parser<S extends Schema.Constraint>(
344 schema: S,
345 options?: SchemaAST.ParseOptions & Options & StreamOptions & { readonly maxFrameSize?: number | undefined }
346): Parser<S["Type"]> {
347 const { exact, exitSuccess, layout, target } = compileTarget(schema)
348 const parseOptions: SchemaAST.ParseOptions = options ?? SchemaAST.defaultParseOptions
349 const decodeTarget = exact
350 ? undefined
351 : Schema.decodeUnknownSync(target as Schema.ConstraintDecoder<unknown>, parseOptions)
352 const decodeEncoded = decodeTarget !== undefined && exitSuccess
353 ? (value: unknown) => isSuccessExit(value) ? value : decodeTarget(value)
354 : decodeTarget
355 return makeParser(
356 layout,
357 compileMode(layout, options?.fingerprint),
358 parseOptions,
359 options?.maxFrameSize,
360 decodeEncoded,
361 requireDictionary(exact, options)
362 )
363}
364
365/**
366 * Options for the connection-scoped pair, {@link encoder} and {@link parser}.

Callers 5

decodeStringFunction · 0.70
decodeFunction · 0.70
FileParseFunction · 0.50
withDefaultFunction · 0.50
parseChecksFunction · 0.50

Calls 6

compileTargetFunction · 0.85
isSuccessExitFunction · 0.85
compileModeFunction · 0.85
requireDictionaryFunction · 0.85
decodeUnknownSyncMethod · 0.80
makeParserFunction · 0.70

Tested by

no test coverage detected