npm.io
0.1.1 • Published 7 years ago

hcl-parser

Licence
MIT
Version
0.1.1
Deps
0
Size
1.5 MB
Vulns
0
Weekly
0

HCL Parser

A better HCL parser for Javascript applications

Overview

This parser is transpiled from hashicorp/hcl using GopherJS.

Installation

npm install hcl-parser

Usage

import {parse} from "hcl-parser"

const input = `
  allow {
    user = "admin"
  }

  deny {
    user = "anonymous"
  }
`

const [data, err] = parse(input);

if(err == null){
  // data is the JSON object you want
} else {
  // handle error
}

Development

In case you may want to reproduce this library

Build

The associated code can be found here anhldbk/hcl-parser

To build the parser:

# Install GopherJS first
go get -u github.com/gopherjs/gopherjs

# Build JS package
gopherjs build github.com/anhldbk/hcl-parser -o lib/parser.js -m
Test
npm test