Skip to content

Releases: nvie/decoders

v2.0.1

07 Jun 11:51
Compare
Choose a tag to compare
  • TypeScript-only: Fix definition of JSONObject to reflect that its values might always be undefined as well.

  • TypeScript-only: Changed return types of { [key: string]: T } to Record<string, T>.

  • TypeScript-only: Fine-tune the type of instanceOf().

v2.0.0

08 Feb 14:10
Compare
Choose a tag to compare

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 🛠️

Bundle size comparison between v1 and v2

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 eithers

Implementation changes:

  • Major reorganization of internal module structure
  • Various simplification of internals

v2.0.0-beta13

07 Feb 12:33
Compare
Choose a tag to compare
v2.0.0-beta13 Pre-release
Pre-release

Upgrading to v2 can, but doesn't have to be a breaking change for you. If upgrading causes errors for you, please see the migration guide for instructions.

v1.25.5

01 Nov 09:33
Compare
Choose a tag to compare
  • Fix compatibility issue with TypeScript projects configured with
    strictNullChecks: false (or strict: false) (Thanks, @stevekrouse and @djlauk!)

  • Officially support Node 16.x

v1.25.4

15 Oct 07:22
Compare
Choose a tag to compare
  • Expose nonEmptyArray function in TypeScript (Thanks, @mszczepanczyk!)

v1.25.3

24 Aug 13:37
Compare
Choose a tag to compare
  • Argument to constant(...) now has to be scalar value in both Flow and TypeScript,
    which matches its intended purpose.

v1.25.2

24 Aug 12:57
Compare
Choose a tag to compare
  • Avoid the need for having to manually specify "as const" in TypeScript when using
    constant(). (Thanks, @schmod!)

v1.25.1

29 Jun 20:13
Compare
Choose a tag to compare
  • Add support for Flow 0.154.0

v1.25.0

23 Jun 08:21
Compare
Choose a tag to compare
  • Fix signature of oneOf() to reflect it can only be used with scalar/constant values

  • In TypeScript, the inferred type for oneOf(['foo', 'bar']) will now be Decoder<'foo' | 'bar'> instead of Decoder<string> 🎉

  • Drop support for Flow versions < 0.115.0

v1.24.1

21 Jun 10:25
Compare
Choose a tag to compare
  • Tighten up signature types to indicate that incoming arrays won't get mutated