0.2.0 • Published 9 years ago
json-assign v0.2.0
json-assign
Object.assign for JSON files.
Quickly write to configurations.
jsonAssign('./package.json', {
name: 'json-assign',
author: 'Jamen Marzonie',
// ...
}, function(err) {
// ...
});Using deep-assign for nested options.
Source function for dynamic replacement
jsonAssign('./package.json', pkg => {
name: pkg.name.toLowerCase()
}, err => {
// ...
});Note: This module is designed bare-bones, it does not ask for confirmation when writing, be warned!
Installation
$ npm install --save json-assignAPI
jsonAssign(target, source, [indent], callback)
Assign an object to a JSON file.
target(String): Path to the JSON file.source(Object,Function): Object or function to assign to the JSON file.indent(Number): Number of spaces in indentation. (Default2)callback(Function): Callback function.
Credits
| Jamen Marzonie |
License
MIT © Jamen Marzonie