Installations
npm install @lozlow/bs-atdgen-codec-runtime
Score
73.4
Supply Chain
86.8
Quality
75.4
Maintenance
100
Vulnerability
98.9
License
Developer
ahrefs
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
18.16.0
NPM Version
9.5.1
Statistics
30 Stars
157 Commits
14 Forks
33 Watching
5 Branches
16 Contributors
Updated on 27 Nov 2024
Bundle Size
219.00 B
Minified
164.00 B
Minified + Gzipped
Languages
OCaml (88.79%)
Perl (5.5%)
Makefile (5.37%)
JavaScript (0.35%)
Total Downloads
Cumulative downloads
Total Downloads
108,837
Last day
50%
3
Compared to previous day
Last week
36.4%
15
Compared to previous week
Last month
-68.8%
306
Compared to previous month
Last year
2,276.4%
104,442
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Dev Dependencies
2
melange-atdgen-codec-runtime
melange-atdgen-codec-runtime
is a Melange runtime for
atdgen. It is based on the Js.Json.t
provided by Melange and combinators of
melange-json.
Installation
Install opam package manager.
Then:
1opam install melange-atdgen-codec-runtime
Usage
To generate ml
files from atd
ones, add a couple of rules to your dune
file:
1(rule 2 (targets test_bs.ml test_bs.mli) 3 (deps test.atd) 4 (action 5 (run atdgen -bs %{deps}))) 6 7(rule 8 (targets test_t.ml test_t.mli) 9 (deps test.atd) 10 (action 11 (run atdgen -t %{deps})))
You can see examples in the tests or the example.
To use the generated modules, you will need to include the runtime library in
your project. To do so, add melange-atdgen-codec-runtime
to the libraries
field in your dune
file:
1; ... 2 (libraries melange-atdgen-codec-runtime) 3; ...
To write atd type definitions, please have a look at the great atd documentation.
Simple example
Reason code to query and deserialize the response of a REST API. It requires melange-fetch.
1let get = (url, decode) => 2 Js.Promise.( 3 Fetch.fetchWithInit( 4 url, 5 Fetch.RequestInit.make(~method_=Get, ()), 6 ) 7 |> then_(Fetch.Response.json) 8 |> then_(json => json |> decode |> resolve) 9 ); 10 11let v: Meetup_t.events = 12 get( 13 "http://localhost:8000/events", 14 Atdgen_codec_runtime.Decode.decode(Meetup_bs.read_events), 15 );
Full example
The example directory contains a full example of a simple cli to read and write data in a JSON file.
For a complete introduction from atdgen installation to json manipulation, please refer to Getting started with ATD and Melange.
No vulnerabilities found.
No security vulnerabilities found.