This release contains quite a lot of changes, but only a few breaking changes.
First the highlight:
This release contains opt-in support for a version of the experimental number suffix feature currently under discussion in the KDL language repository.
import {parse} from "@bgotink/kdl";
import assert from "node:assert";
assert.throws(() => parse("node 10xp"));
assert.doesNotThrow(() =>
parse("node 10px", {
flags: {
experimentalSuffixedNumbers: true,
},
}),
);Changes:
- Start on KDL Query implementation
- Rewrite the entire tokenizer to use a lookup table, which provides a drastic speed boost
- The v1 parser is rebuilt from scratch and uses the same infrastructure as the existing v2 parser.
This makes parsing a v1 document not only 2x faster but it stops us from having to bundle chevrotain with its heavy footprint. - Fix issues with the
format()function: improve its ability to format bare identifiers and fix unicode escapes. - BREAKING CHANGE: in case multiple errors occur the parser will now throw an
InvalidKdlErrorrather than anAggregateError.
TheInvalidKdlErrorcan now have sub-errors in itserrorsproperty. You can use theflat()method to easily iterate over all errors contained within anInvalidKdlError. - Add support for (a version of) the number suffix feature under discussion in the KDL language repository.
- BREAKING CHANGE: place support for number suffixes behind a parser flag.
Note this is only a breaking change if you are updating from one of the 0.4.0-next releases. - Expose value tags in the
DeserializationContextAPI (#12). - BREAKING CHANGE: The
DeserializationContext#runfunction now leave theDeserializationContextunchanged if the deserializer throws an error instead of leaving the context in an inconsistent and unpredictable state.
This means you can safely try multiple deserializers, which is further aided by the newcontext.run.try()function.
Full Changelog: v0.3.1...v0.4.0