arktype
arktype copied to clipboard
Allow nodes to be serialized to their input formats
Would add a node method "serialize" (or similar, will have to think about details as not all nodes will be serializable in a way they could be restored) that would convert a node instance to its input format, e.g:
const t = type("string");
// { basis: "string" }
const serialized = t.root.serialize();
The existing node
API already exists as a way to deserialize this format, but this would be a good opportunity to ensure they are correctly aligned and enforce that at a type-level.