0.2.0 • Published 8 years ago

json-assign v0.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

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

API

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. (Default 2)
  • callback (Function): Callback function.

Credits

jamen
Jamen Marzonie

License

MIT © Jamen Marzonie