postjson

0.1.3 • Public • Published

postjson npmjs.com The MIT License

Transforming JSON with plugins.

code climate standard code style travis build status coverage status dependency status

Install

npm i postjson --save

Usage

For more use-cases see the tests

const postjson = require('postjson')

PostJSON

Initialize a PostJSON optionally with plugins and options.

Params

  • plugins {Array|Function}
  • options {Object}

.use

Add a fn as plugin.

Params

  • fn {Functio|Array}
  • options {Object}
  • returns {PostJSON}: instance for chaining

.parse

Parse a str to abstract syntax tree (AST) and writes it to .tree property of the this instance.

Params

  • str {String}
  • options {Object}
  • returns {PostJSON}: instance for chaining

.render

Render a given tree. Or you can just use it in combination with .parse(str) which writes the tree to instance, then .render will use it. If only one argument is passed it is assumed as options.

Params

  • tree {Object}: (optional) Abstract Syntax Tree, otherwise will use this.tree
  • options {Object}
  • returns {PostJSON}: instance for chaining

.toString

Returns stringified and already modified JSON.

Params

  • indent {Object}
  • returns {String}

.process

Transforms a val using previously passed plugins. Think for it like .parse plus .render combination.

Params

  • val {String}
  • options {Object}
  • returns {PostJSON}

.walk

Temporary here, could be plugin. Part of future API sugars for working with AST.

Params

  • tree {Object|Array}
  • fn {Function}
  • returns {PostJSON}

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckoCore.tk keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github

Package Sidebar

Install

npm i postjson

Weekly Downloads

0

Version

0.1.3

License

MIT

Last publish

Collaborators

  • vanchoy
  • tunnckocore