m_config
v1.0.1
Published
retrieve and set config from a flat JSON file
Downloads
3
Readme
m_config
Dead simple config, read and save a javascript object from a file.
install
npm install m_config --save
usage
save
const config = require('m_config')('./config.json');
// save important config...
// save replaces the files contents
config.save({
wrong: true
})
// saves file: config.json with { wrong: true }
config.save({
demo: '123',
hi_ho_silver: true,
herp_derp: false
});
// non destructive merging...
config.merge({ a: true })
.merge({ b: false })
.merge({ c: 'hi ho silver!' })
.load(function (err, data) {
if(!err) console.log(data);
});
// file contents has been replaced with the above options.
load
// load saved config...
config.load(function (err, config) {
if (!err) {
console.log(typeof config); // 'object'
console.log(config.demo); // '123'
console.log(config.wrong) // undefined
}
})
chainable to some extent!
config.save({
should_not_see_me: 'yolo!!'
}).empty();