-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
178 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.re linguist-language=Reason |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# keep the tests and docs out of npm | ||
test | ||
/docs | ||
/website | ||
CONTRIBUTING.md | ||
CHANGELOG.md | ||
|
||
# ...plus all of the stuff from gitignore | ||
node_modules | ||
*/log | ||
.vscode | ||
|
||
# generated | ||
/lib/bs | ||
*.bs.js | ||
/dist | ||
.merlin | ||
.bsb.lock | ||
/coverage | ||
|
||
# os files | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
## Unreleased | ||
|
||
The following changes are currently in the `master` branch but have not been published in a tagged release yet. | ||
|
||
### :rotating_light: Breaking | ||
|
||
- `Decode.ParseError.map` has been removed (it wasn't used internally or documented) | ||
|
||
### :bug: Bug fixes | ||
|
||
- `...AsResult.OfStringNel` actually collects multiple errors now | ||
|
||
### :sparkles: New features | ||
|
||
- `Decode.alt` allows combining decode functions and picking the first success | ||
- `...AsResult.OfStringNel` now includes all of the same `map`, `flatMap`, etc functions for decoders | ||
|
||
### :heavy_check_mark: Code quality | ||
|
||
- Reorganize tests so that `...AsOption` tests decoders pass-vs-fail, `...AsResult` tests failure reporting | ||
- Test coverage has increased to 100% | ||
- Internally, many functions were re-written to use `map`, `flatMap`, `alt`, etc on the functions themselves, rather than running the decoders and transforming the output | ||
- `Js.Dict.key` was changed to `string` in interface files for better editor suggestions | ||
|
||
## 0.5.1 (May 22, 2019) | ||
|
||
### :heavy_check_mark: Code quality | ||
|
||
- Bump Relude dependency to the latest version | ||
- Add continuous integration and coverage reporting | ||
|
||
## 0.5.0 (May 13, 2019) | ||
|
||
### :rotating_light: Breaking | ||
|
||
- `Decode.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 `NonEmptyList`s 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 | ||
- `Decode.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](https://github.com/reazen/relude) exist if you want to work with `option` and `result` types. (#33) | ||
|
||
### :sparkles: New features | ||
|
||
- Decode functions now have `map`, `apply`, `map2`...`map5`, and `flatMap` functions, meaning you can transform decoders before actually running them. (#23) | ||
- `Decode.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) | ||
- `Decode.Pipeline` aliases most of the base decoders (e.g. `string`, `intFromNumber`, etc), so locally-opening `Decode.Pipeline` should get you everything you need (#27) | ||
|
||
### :heavy_check_mark: Code quality | ||
|
||
- Internal use of infix functions has been greatly reduced to improve code clarity | ||
- Tests have fewer global opens and fewer aliased functions | ||
|
||
## 0.4.0 (Jan 24, 2019) | ||
|
||
### :rotating_light: Breaking | ||
|
||
- `float` and `int` are now `floatFromNumber` and `intFromNumber` to avoid compiler warnings related to shadowing `Pervasives.float` | ||
|
||
### :sparkles: New features | ||
|
||
- `Decode.date` decodes numbers or ISO-8601 strings into `Js.Date.t` | ||
- `Decode.oneOf` attempts multiple decoders | ||
- `Decode.dict` decodes an object into a `Js.Dict.t` | ||
- `Decode.variantFromJson` (and `variantFromString`, `variantFromInt`) decode JSON values directly into Reason variants | ||
- `Decode.Pipeline.at` now brings `at` functionality into the pipeline, to allow digging into nested JSON objects | ||
|
||
### :memo: Documentation | ||
|
||
- The `docs/` folder has more content | ||
- The website is unpublished but mostly finished | ||
|
||
## 0.3.3 (Oct 12, 2018) | ||
|
||
### :bug: Bug fixes | ||
|
||
- `Decode.int` now works correctly with `0` | ||
|
||
## 0.3.1 (Oct 12, 2018) | ||
|
||
### :sparkles: New features | ||
|
||
- `Decode.AsResult.OfStringNel` now provides a consistent `ResultUtil` module that matches `...OfParseError` | ||
|
||
### :heavy_check_mark: Code quality | ||
|
||
- `*.rei` files now exist to help with editor suggestions | ||
|
||
|
||
## 0.3.0 (Oct 10, 2018) | ||
|
||
### :rotating_light: Breaking | ||
|
||
- Rename `decode*` functions (e.g. `decodeString` is now `string`) | ||
- Flip arguments to `Pipeline.run` so it can be piped with `|>` (thanks @gavacho) | ||
|
||
### :sparkles: New features | ||
|
||
- `Decode.boolean` was missing but now exists (thinks @johnhaley81) | ||
|
||
## 0.2.0 (Sep 28, 2018) | ||
|
||
### :rotating_light: Breaking | ||
|
||
- Basic failure type is now a polymorphic variant so it's easier to extend with custom validations | ||
- Many submodules were renamed and reorganized | ||
|
||
### :sparkles: New features | ||
|
||
- `Decode` top-level modules provides a convenient way to access everything | ||
|
||
### :memo: Documentation | ||
|
||
- Some basic examples now exist | ||
|
||
## 0.1.0 (Sep 24, 2018) | ||
|
||
Initial release includes basic decode functions and the choice of decoding into an `option` or a `Belt.Result.t` with recursively structured errors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
### Getting Started | ||
|
||
1. Fork [this repo on Github](https://github.com/mlms13/bs-decode) and clone it locally | ||
2. `npm install` to grab dependencies | ||
3. `npm run cleanbuild && npm run test` to build and run tests | ||
4. Make your changes (and add appropriate tests) | ||
5. [Open a pull request](https://help.github.com/en/articles/about-pull-requests) with your changes | ||
|
||
### Code style and conventions | ||
|
||
We use [Relude](https://github.com/reazen/relude/) as our standard library, so try to avoid using `Belt` or `Pervasives` when working with lists, options, etc. | ||
|
||
To make the code easier to understand for other new contributors, we've tried to minimize our use of infix functions. Using `>>` for forward composition is fine, though. | ||
|
||
Also, please make sure that your code has been formatted with [`refmt`](https://reasonml.github.io/docs/en/editor-plugins). | ||
|
||
### Project structure | ||
|
||
- `DecodeBase.re` is where all of the decoders are defined | ||
- `Decode_As*.re` modules construct `DecodeBase` with everything it needs to produce decoders for a specific output type (e.g. `option`, `result`) | ||
- `Decode_ParseError.re` defines the structured errors and helper functions to work with `Belt.Result.t` values of that error type | ||
|
||
### Tests | ||
|
||
`bs-decode` currently has 100% test coverage, and we hope to keep it that way. :) Running `npm run test` (or `jest --coverage`) will run your tests and give you a coverage report. You can see the detailed report in `./coverage/lcov-report/index.html`, which will help you track down any uncovered functions or branches. | ||
|
||
### Documentation | ||
|
||
The documentation website is currently generated with [Docusaurus](https://docusaurus.io/). For more information on contributing to, running, and publishing the website, see [the README in the website folder](https://github.com/mlms13/bs-decode/blob/master/website/README.md). | ||
|
||
Separately from the website, we maintain `*.rei` interface files that provide type hints and doc comments to editors. When adding new functionality, make sure you update the appropriate interface files with type signatures and comments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters