MCPcopy Create free account
hub / github.com/arktypeio/arktype / versionableAssertion

Function versionableAssertion

ark/attest/assert/assertions.ts:56–80  ·  view source on GitHub ↗
(fn: AssertFn)

Source from the content-addressed store, hash-verified

54
55export const versionableAssertion =
56 (fn: AssertFn): AssertFn =>
57 (expected, actual, ctx) => {
58 if (actual instanceof TypeAssertionMapping) {
59 if (!ctx.typeAssertion) {
60 throwInternalError(
61 `Unexpected missing typeAssertion when passed a TypeAssertionMapper`
62 )
63 }
64 try {
65 const mapped = actual.fn(ctx.typeAssertion, ctx)
66 if (mapped !== null) {
67 fn(
68 "expected" in mapped ? mapped.expected : expected,
69 mapped.actual,
70 ctx
71 )
72 }
73 } catch (e) {
74 throwAssertionError({
75 stack: ctx.assertionStack,
76 message: `${e}`
77 })
78 }
79 } else fn(expected, actual, ctx)
80 }
81
82// node:assert prints the values of a failed deepStrictEqual in full, which
83// for a live graph like a Type's exhausts memory (#1287), so only plain data

Callers 1

assertions.tsFile · 0.85

Calls 3

throwInternalErrorFunction · 0.90
throwAssertionErrorFunction · 0.85
fnFunction · 0.50

Tested by

no test coverage detected