(
base: Code,
representation: Exclude<SchemaRepresentation.Representation, SchemaRepresentation.Reference>,
path: Path
)
| 319 | } |
| 320 | |
| 321 | function applyNode( |
| 322 | base: Code, |
| 323 | representation: Exclude<SchemaRepresentation.Representation, SchemaRepresentation.Reference>, |
| 324 | path: Path |
| 325 | ): Code { |
| 326 | let runtime = code`${base.runtime}${runtimeAnnotate(representation.annotations)}` |
| 327 | for (let index = 0; index < representation.checks.length; index++) { |
| 328 | const check = representation.checks[index] |
| 329 | const compiledCheck = compileCheck(check, [...path, "checks", index]) |
| 330 | // Only collapse a bare number's leading canonical check. |
| 331 | const current = runtime |
| 332 | runtime = deferred((render) => { |
| 333 | const base = render(current) |
| 334 | const check = render(compiledCheck) |
| 335 | const namespace = render(schemaImport) |
| 336 | const suffix = check.startsWith(namespace + ".") ? check.slice(namespace.length) : "" |
| 337 | return base === `${namespace}.Number` && Object.hasOwn(canonicalNumberChecks, suffix) |
| 338 | ? namespace + canonicalNumberChecks[suffix] |
| 339 | : `${base}.check(${check})` |
| 340 | }) |
| 341 | } |
| 342 | return makeFragments(runtime, base.Type) |
| 343 | } |
| 344 | |
| 345 | function recur( |
| 346 | representation: SchemaRepresentation.Representation, |
no test coverage detected