merge-settings v0.2.0
merge-settings

Load and merge configuration settings from multiple sources, in a specific order, and normalized according to a schema.
Install
Install with npm:
$ npm install merge-settings --saveUsage
var Settings = require('merge-settings');API
Settings
Create an instance of Settings with the given options.
Params
options{Object}
Example
var settings = new Settings();.set
Add a config object to be merged.
Params
object{Object}: The object to merge into the config.
Example
config
.addConfig({a: 'b', c: 'd'})
.addConfig({a: 'z'})
.merge();
//=> {a: 'z', c: 'd'}.get
Get the normalized value of property key from the cache.
Params
key{String}returns{any}: The normalized value ofkey
Example
config.get('foo');.getRaw
Get the raw (non-normalized) value of property key from the cache.
Params
key{String}returns{any}: The value ofkey
Example
config.get('foo');.addConfig
Add a config object to be merged.
Params
object{Object}: The object to merge into the config.
Example
config
.addConfig({a: 'b', c: 'd'})
.addConfig({a: 'z'})
.merge();
//=> {a: 'z', c: 'd'}.addConfigs
Add an array or list of config objects to be merged.
Params
object{Object}: The object to merge into the config.
Example
config
.addConfigs({a: 'b'}, {c: 'd'})
.addConfigs([{a: 'b'}, {c: 'd'}]).merge
Merge the given (optional) config object with cached config objects in the order in which the objects were defined. If a normalize function is passed on the contructor options, or as the first or second argument to .merge, it will be used on each config object before merging it onto the results object.
Params
config{Object}
Example
var settings = new Settings()
.set('foo', {a: 'b'})
.set('bar', {c: 'd'})
.set('baz', {e: 'f'})
.merge();
console.log(settings);
//=> {a: 'b', c: 'd', e: 'f'}
// Pass a normalize function on the
// ctor options, or to .merge as first or second arg
var settings = new Settings()
.set('foo', {a: 'b'})
.set('bar', {c: 'd'})
.set('baz', {e: 'f'})
.merge(function(config) {
// normalize config object
});
console.log(settings);
//=>Related projects
You might also be interested in these projects:
- base: base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… more | homepage
- data-store: Easily get, set and persist config data. | homepage
- extend-shallow: Extend an object with the properties of additional objects. node.js/javascript util. | homepage
- mixin-deep: Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone. | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Building docs
Generate readme and API documentation with verb:
$ npm install verb && npm run docsOr, if verb is installed globally:
$ verbRunning tests
Install dev dependencies:
$ npm install -d && npm testAuthor
Jon Schlinkert
License
Copyright © 2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb, v0.9.0, on April 07, 2016.