consequitur-kdl
v0.3.2
Published
A consequitur schema written in KDL, read into the schema object and written back.
Readme
consequitur-kdl
A consequitur schema written in KDL, read into the schema object and written back.
A schema is JSON; this package reads and writes it as KDL, the form a person writes: the head, each gist, the laws, and every condition as nodes. Problems come back at their line and column.
npm install consequitur-kdl consequiturimport { readSchema, BASE_KIT } from 'consequitur';
import { fromKdl, toKdl } from 'consequitur-kdl';
const { json, problems } = fromKdl(text);
if (problems.length > 0) throw new Error(problems.map((p) => `${p.line}:${p.column} ${p.message}`).join('\n'));
const { schema, problems: more } = readSchema(json, BASE_KIT); // the same reader as for a JSON schema
toKdl(json); // back to textfromKdl checks the text's shape; readSchema then reads the object exactly as it reads a schema.json. The text a schema is written to by toKdl reads back to the same object.
Dependencies: consequitur, kdlet-guards (its kdlet-guards/kdl entry reads and writes a condition's nodes) and @bgotink/kdl, which parses and formats KDL.
Documents
The documents are in five shelves: tutorial, how-to guides, reference, explanation and project, all in docs/ of the repository.
MIT.
