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

Function asSync

packages/effect/src/SchemaParser.ts:1000–1012  ·  view source on GitHub ↗
(
  parser: (input: E, options?: SchemaAST.ParseOptions) => Effect.Effect<T, SchemaIssue.Issue>
)

Source from the content-addressed store, hash-verified

998}
999
1000function asSync<T, E>(
1001 parser: (input: E, options?: SchemaAST.ParseOptions) => Effect.Effect<T, SchemaIssue.Issue>
1002): (input: E, options?: SchemaAST.ParseOptions) => T {
1003 const parserExit = asExit(parser)
1004 return (input: E, options?: SchemaAST.ParseOptions) => {
1005 const exit = parserExit(input, options)
1006 if (Exit.isSuccess(exit)) {
1007 return exit.value
1008 }
1009 const issue = InternalSchemaCause.getSchemaIssueOrThrow(exit.cause, "Sync adapter can only throw schema issues")
1010 throw new Error("Schema validation failed", { cause: issue })
1011 }
1012}
1013
1014/** @internal */
1015export interface Parser {

Callers 2

decodeUnknownSyncFunction · 0.85
encodeUnknownSyncFunction · 0.85

Calls 1

asExitFunction · 0.85

Tested by

no test coverage detected