Skip to content

postjson/postjson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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')

Initialize a PostJSON optionally with plugins and options.

Params

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

Add a fn as plugin.

Params

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

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 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

Returns stringified and already modified JSON.

Params

  • indent {Object}
  • returns {String}

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

Params

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

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.

tunnckoCore.tk keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github

About

🔥 Transforming JSON with plugins.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published