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

Function withId

ark/schema/parse.ts:476–489  ·  view source on GitHub ↗
(node: node, id: NodeId)

Source from the content-addressed store, hash-verified

474}
475
476export const withId = <node extends BaseNode>(node: node, id: NodeId): node => {
477 if (node.id === id) return node
478 if (isNode(nodesById.get(id)))
479 throwInternalError(`Unexpected attempt to overwrite node id ${id}`)
480 // have to ignore cache to force creation of new potentially cyclic id
481 return createNode({
482 id,
483 kind: node.kind,
484 inner: node.inner,
485 meta: node.meta,
486 $: node.$,
487 ignoreCache: true
488 }) as never
489}
490
491export const withMeta = <node extends BaseNode>(
492 node: node,

Callers 4

resolveContextFunction · 0.90
resolveDefinitionFunction · 0.90
parseDefFunction · 0.90
parseReturnedFunction · 0.90

Calls 4

isNodeFunction · 0.90
throwInternalErrorFunction · 0.90
createNodeFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected