MCPcopy
hub / github.com/Effect-TS/effect / asserts

Function asserts

packages/effect/src/ParseResult.ts:677–688  ·  view source on GitHub ↗
(schema: Schema.Schema<A, I, R>, options?: AST.ParseOptions)

Source from the content-addressed store, hash-verified

675 * @since 3.10.0
676 */
677export const asserts = <A, I, R>(schema: Schema.Schema<A, I, R>, options?: AST.ParseOptions) => {
678 const parser = goMemo(AST.typeAST(schema.ast), true)
679 return (u: unknown, overrideOptions?: AST.ParseOptions): asserts u is A => {
680 const result: Either.Either<any, ParseIssue> = parser(u, {
681 exact: true,
682 ...mergeInternalOptions(options, overrideOptions)
683 }) as any
684 if (Either.isLeft(result)) {
685 throw parseError(result.left)
686 }
687 }
688}
689
690/**
691 * @category encoding

Callers 1

asserts.test.tsFile · 0.85

Calls 4

goMemoFunction · 0.85
parserFunction · 0.85
mergeInternalOptionsFunction · 0.85
parseErrorFunction · 0.70

Tested by

no test coverage detected