v2.0.0
This is a breaking change, which brings numerous benefits:
- A simpler API π
- Smaller bundle size (67% reduction π±)
- Tree-shaking support π
- Runtime speed ποΈ
- Better documentation π
- Better support for writing your own decoders π οΈ
Please see the migration guide for precise instructions on how to
adjust your v1 code.
The main change is the brand new Decoder<T>
API! The tl;dr is:
Replace this v1 pattern... | ...with this v2 API | Notes | |
---|---|---|---|
mydecoder(input) |
β | mydecoder.decode(input) |
migration instructions |
guard(mydecoder)(input) |
β | mydecoder.verify(input) |
migration instructions |
map(mydecoder, ...) |
β | mydecoder.transform(...) |
migration instructions |
compose(mydecoder, predicate(...)) |
β | mydecoder.refine(...) |
migration instructions |
describe(mydecoder, ...) |
β | mydecoder.describe(...) |
|
mydecoder(input).value() |
β | mydecoder.value(input) |
|
either , either3 , ..., either9 |
β | either |
migration instructions |
tuple1 , tuple2 , ... tuple6 |
β | tuple |
migration instructions |
dispatch |
β | taggedUnion |
migration instructions |
url(...) |
β | httpsUrl / url (signature has changed) |
migration instructions |
The full documentation is available on decoders.cc.
Other features:
- Include ES modules in published NPM builds (yay tree-shaking! π)
- Much smaller total bundle size (67% smaller compared to v1 π±)
Other potentially breaking changes:
- Drop support for all Node versions below 12.x
- Drop support for TypeScript versions below 4.1.0
- Drop support for Flow versions below 0.142.0
- Drop all package dependencies
- Direct reliance on
lemons
has been removed
New decoders:
Other improvements:
optional()
,
nullable()
, and
maybe()
now each take an optional 2nd param to
specify a default value- Better error messages for nested
either
s
Implementation changes:
- Major reorganization of internal module structure
- Various simplification of internals