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

Function runWithCompiler

packages/effect/src/SchemaParser.ts:928–946  ·  view source on GitHub ↗
(compiler: Compiler, ast: SchemaAST.AST)

Source from the content-addressed store, hash-verified

926}
927
928function runWithCompiler<T, R>(compiler: Compiler, ast: SchemaAST.AST) {
929 let parser: Parser
930 return (input: unknown, options?: SchemaAST.ParseOptions): Effect.Effect<T, SchemaIssue.Issue, R> => {
931 const result = (parser ??= compiler(ast))(
932 input,
933 options ?? SchemaAST.defaultParseOptions
934 )
935 if (result === InternalParser.sameExit) {
936 return Effect.succeed(input) as Effect.Effect<T, SchemaIssue.Issue, R>
937 }
938 if (!effectIsExit(result)) {
939 return Effect.flatMapEager(result, getValue)
940 }
941 return (result as InternalParser.Success<unknown, SchemaIssue.Issue>)[InternalParser.args] ===
942 InternalParser.missing
943 ? getValue(InternalParser.missing)
944 : result as Effect.Effect<T, SchemaIssue.Issue, R>
945 }
946}
947
948function asPromise<T, E>(
949 parser: (input: E, options?: SchemaAST.ParseOptions) => Effect.Effect<T, SchemaIssue.Issue>

Callers 2

makeEffectFunction · 0.85
runFunction · 0.85

Calls 3

effectIsExitFunction · 0.90
getValueFunction · 0.85
succeedMethod · 0.45

Tested by

no test coverage detected