https://github.com/jamen/json-assign
Object.assign for JSON files.
https://github.com/jamen/json-assign
Last synced: 9 months ago
JSON representation
Object.assign for JSON files.
- Host: GitHub
- URL: https://github.com/jamen/json-assign
- Owner: jamen
- License: mit
- Created: 2016-07-10T01:12:04.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-07-10T01:12:55.000Z (almost 10 years ago)
- Last Synced: 2025-08-03T19:08:20.430Z (11 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# json-assign
> Object.assign for JSON files.
Quickly write to configurations.
```javascript
jsonAssign('./package.json', {
name: 'json-assign',
author: 'Jamen Marzonie',
// ...
}, function(err) {
// ...
});
```
Using `deep-assign` for nested options.
Source function for dynamic replacement
```javascript
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
```shell
$ 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][avatar] |
|:---:|
| [Jamen Marzonie][github] |
## License
[MIT](LICENSE) © Jamen Marzonie
[avatar]: https://avatars.githubusercontent.com/u/6251703?v=3&s=125
[github]: https://github.com/jamen