decgen

1.0.3 • Public • Published

Elm coders generator

Builds JSON decoders and encoders for your Elm types.

Demo using the kakoune editor piping to the CLI. asciicast

Installation

npm i -g decgen

CLI

Generate decoders for Example.elm (available in this repo):

It grabs and generates code only for type definitions inside these annotations.

decgen Example.elm

Or pipe to decgen:

echo '-- [decgen-start]\n type X = Int\n-- [decgen-end]' | decgen 

output

-- [decgen-start]
 type X = Int
 
-- [decgen-generated-start] -- DO NOT MODIFY or remove this line
decodeX =
   Decode.int
 
encodeX a =
   Encode.int a 
-- [decgen-end]

API

const generate = require('decgen')

generate('-- [decgen-start]\n type X = Int\n -- [decgen-end]').then(x => console.log(x))

// -> decodeX =
// ->    Decode.int
// -> 
// -> encodeX a =
// ->    Encode.int a

Development

Clone the repo and build Cli.elm:

$ git clone https://github.com/dkodaj/decgen
$ cd decgen
$ elm make src/Cli.elm --output src/Cli.js --optimize

Readme

Keywords

none

Package Sidebar

Install

npm i decgen

Weekly Downloads

0

Version

1.0.3

License

ISC

Unpacked Size

134 kB

Total Files

6

Last publish

Collaborators

  • franzskuffka