Package Exports
- json-chain
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (json-chain) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
🎀⛓ json-chain
fluent chaining for json with dot-prop access
📦 usage
yarn add json-chain
npm i json-chain --saveconst JSONChain = require('json-chain')📘 examples
const data = {
eh: ['og'],
canada: true,
}
const chain = JSONChain.init(data).update('eh', ['some values'])👓 reading json file
const {readFileSync} = require('fs')
const pkg = readFileSync('./package.json', 'utf8')
const chain = new JSONChain(pkg)
.parse() // will be done automatically, is optional
.set('eh', ['some values']) // also as .update
.del('eh') // also as .delete, .remove
// also as .val
const test = chain.get('scripts.test')
const has = chain.has('version')✍ writing to file
- has
.toStringand.toJSONmethods for auto-stringifying when cast tostringorJSON.stringify
👾 keep it simple
const chain = new JSONChain(pkg)
.updateIfNotEmpty('scripts.test', 'ava --verbose')
.updateIfNotEmpty('scripts.devDependencies', {'ava': '*'})
.write()