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

Function applyNode

packages/effect/src/internal/schema/schemaCodegen.ts:321–343  ·  view source on GitHub ↗
(
    base: Code,
    representation: Exclude<SchemaRepresentation.Representation, SchemaRepresentation.Reference>,
    path: Path
  )

Source from the content-addressed store, hash-verified

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,

Callers 1

recurFunction · 0.85

Calls 7

codeFunction · 0.90
deferredFunction · 0.90
runtimeAnnotateFunction · 0.85
makeFragmentsFunction · 0.85
sliceMethod · 0.80
compileCheckFunction · 0.70
renderFunction · 0.50

Tested by

no test coverage detected