arktype icon indicating copy to clipboard operation
arktype copied to clipboard

Allow nodes to be serialized to their input formats

Open ssalbdivad opened this issue 1 year ago • 0 comments

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.

ssalbdivad avatar Jul 09 '23 18:07 ssalbdivad