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

Function writeMorph

ark/type/standalone/combinators.ts:1191–1212  ·  view source on GitHub ↗
(js: CombinatorCompiler, node: MorphNode)

Source from the content-addressed store, hash-verified

1189
1190// a callback is read where it's called, as it may be set once this has loaded
1191const writeMorph = (js: CombinatorCompiler, node: MorphNode): string =>
1192 writeCall(
1193 "morphing",
1194 node.head ? readChecker(js, node.head) : "0",
1195 `[${node.travMorphs
1196 .slice(node.head ? 1 : 0)
1197 .map(step => {
1198 if (!hasArkKind(step, "root")) {
1199 return isKeyword(step) ?
1200 js.ref(step)
1201 : `data => ${js.ref(step)}(data)`
1202 }
1203 // a morph references only its last step
1204 js.link.byId[step.id] ??= step
1205 return writeCall(
1206 "piped",
1207 readChecker(js, step),
1208 step.reportsPred ? "1" : undefined
1209 )
1210 })
1211 .join(", ")}]`
1212 )
1213
1214// what narrows a checker after it, which one that transforms writes apart, so
1215// a program narrowing no transform ships only the other

Callers 1

writeCheckerFunction · 0.85

Calls 6

hasArkKindFunction · 0.90
isKeywordFunction · 0.90
writeCallFunction · 0.85
readCheckerFunction · 0.85
mapMethod · 0.65
refMethod · 0.45

Tested by

no test coverage detected