1.0.3 • Published 5 years ago

decgen v1.0.3

Weekly downloads
5
License
ISC
Repository
github
Last release
5 years ago

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
1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago