Skip to content

Releases: mlms13/bs-decode

v0.7.0

25 Jun 23:17
Compare
Choose a tag to compare

🚨 Breaking

  • relude and bs-abstract are now peerDependencies. This means you'll need to add these dependencies to your own package.json, and you're much less likely to end up with duplicate versions of these packages.

v0.6.2

07 Jun 23:01
Compare
Choose a tag to compare

🐛 Bug fixes

  • Decode.array (and its friend list) had a regression where they could fail in some browsers when given large amounts of data, but stack safety has been restored

v0.6.1

07 Jun 23:00
Compare
Choose a tag to compare

This release cleans up our package on npm but has no API changes.

✔️ Code quality

  • Fix links in package.json

v0.6.0

28 May 02:22
Compare
Choose a tag to compare

🚨 Breaking

  • Decode.fallback doesn't assume you want to work with fields, but you can use Decode.(fallback(field("x", string), "default")) if you want the old behavior
  • Decode.Pipeline.fallback has the same new behavior, but it provides fallbackField to achieve the old behavior
  • Decode.ParseError.map has been removed (it wasn't used internally or documented)
  • The Decode.ParseError variant type now includes a TriedMultiple constructor. This is only a breaking change if you are matching directly on values of this type.

🐛 Bug fixes

  • Decode.AsResult.OfStringNel actually collects multiple errors now

✨ New features

  • Decode.alt allows combining decode functions and picking the first success
  • Decode.AsResult.OfStringNel now includes all of the same map, flatMap, etc functions for decoders
  • Decode.ParseError is aliased as Decode.AsResult.OfParseError.ParseError so parse errors can be accessed from an aliased decode module

✔️ Code quality

  • Reorganize tests so that Decode_AsOption tests decoders pass-vs-fail, Decode_AsResult_* tests failure reporting
  • Test coverage has increased to 100%
  • Internally, many functions were re-written to use map, flatMap, alt, etc on the decoders themselves, rather than running the decoders and transforming the output
  • Js.Dict.key was changed to string in interface files for better editor suggestions

v0.5.1

23 May 00:17
Compare
Choose a tag to compare

bs-decode now compiles with Relude 0.12.1. There is no change to the public API in this release.

v0.5.0

13 May 17:21
Compare
Choose a tag to compare

This release focuses on cleaning up our public API and our internal tooling. Additionally, decoders are easier to compose, so you should be able to do more mapping/flatMapping on the decode functions directly (before running the decoders), instead of needing to transform the output (after running the decoders).

🚨 Breaking

  • oneOf now takes a single decoder, followed by a list of decoders instead of requiring you to construct a NonEmptyList (#28)
  • Decode.ok has been removed, if you want to construct a decoder that always succeeds (ignoring the JSON input), use Decode.pure instead.
  • Decoders that produce NonEmptyLists of errors now use Relude.NonEmpty.List instead of the implementation from bs-nonempty due to more active maintenance and a broader collection of helper functions
  • D.ResultUtils is no longer part of the public interface. Decode functions themselves are more easily composable (see "New stuff" below), so there's less need to transform the output after decoding. Plus better libraries exist if you want to work with option and result types. (#33)

✨ New stuff

  • Decoders (the functions from Js.Json.t to option or Result.t) now have map, apply, map2...map5, and flatMap functions, meaning you can transform decoders before actually running them. (#23)
  • D.NonEmptyList is exposed for all decode modules that return a NonEmptyList of errors. This means you can do basic operations with the errors without bringing in an additional library (#24)
  • D.Pipeline aliases most of the base decoders (e.g. string, intFromNumber, etc), so locally-opening D.Pipeline should get you everything you need (#27)

✔️ Internal cleanup

  • Internal use of infix functions has been greatly reduced to improve code clarity
  • Tests have fewer global opens and fewer aliased functions

Release 0.4.0

24 Jan 19:44
Compare
Choose a tag to compare

It had been too long! Sorry about that! Lots of great work went into this release:

  • Add oneOf to attempt multiple decoders before failing
  • Decode directly into Js.Dict.t with the dict decoder
  • Decode dates from floats or ISO-8601 strings
  • Decode directly into Reason variants without having to extend DecodeBase
  • Use at in the Pipeline to dig through nested JSON objects
  • Breaking: deprecate int and float to avoid compiler complaints with local opens. Use intFromNumber and floatFromNumber now instead.

Additionally, lots of work is going in to docs and improving the examples. The docs site isn't up just yet, but it should be shortly.

Decode zero as int

24 Oct 20:26
Compare
Choose a tag to compare

There was a divide-by-zero bug when trying to decode 0 as an int... it's fixed now.

v0.3.1 interface files

12 Oct 18:11
Compare
Choose a tag to compare
  • ResultUtil is now more consistent between OfParseError and OfStringNel
  • Interface files! No longer will editor suggestions and compiler errors talk about BsAbstract.Option.Monad.t

v0.3.0 now with booleans and a cleaner API

10 Oct 19:52
Compare
Choose a tag to compare
  • decodeString is now just string; same for field, optional, int, and everything else
  • we can now decode booleans (oops, quite the oversight, thanks to @johnhaley81 for the fix!)
  • the arguments to Pipeline.run are now flipped, meaning you can chain |> run(json) using the normal pipe instead of the fast pipe (thanks @gavacho!)