m_config

1.0.1 • Public • Published

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();

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    1
  • 0.0.1
    0

Package Sidebar

Install

npm i m_config

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • m-onz