Map configuration objects to application methods.
npm install map-config> Map configuration objects to application methods.
Install with npm:
``sh`
$ npm i map-config --save
`js`
var MapConfig = require('map-config');
Params
* app {Object}: Object containing the methods that will be called based on the map specification. map
* {Object}: Optional object specifying how to map a configuration to an application.
Example
`js`
var mapper = new MapConfig(app, map);
Params
* key {String}: property key to map. val
* {Function|Object}: Optional function to call when a config has the given key. Functions will be passed (val, key, config) when called. Functions may also take a callback to indicate async usage. May also pass another instance of MapConfig to be processed. returns
* {Object} this: to enable chaining
Example
`js`
mapper
.map('baz')
.map('bang', function(val, key, config) {
});
for property key.Params
*
alias {String}: Alias to use for key.
* key {String}: Actual property or method on app.
* returns {Object}: Returns the instance for chaining. Example
`js
mapper.alias('foo', 'bar');
`$3
Process a configuration object with the already configured map and app.Params
*
config {Object}: Configuration object to map to application methods.
* cb {Function}: Optional callback function that will be called when finished or if an error occurs during processing. Example
`js
mapper.process(config);
`$3
Add a key to the .keys array. May also be used to add an array of namespaced keys to the .keys array. Useful for mapping "sub-configs" to a key in a parent config.Params
*
key {String}: key to push onto .keys
* arr {Array}: Array of sub keys to push onto .keys
* returns {Object} this: for chaining Example
`js
mapper.addKey('foo');
console.log(mapper.keys);
//=> ['foo']var one = new MapConfig();
var two = new MapConfig();
two.map('foo');
two.map('bar');
two.map('baz');
// map config
two to config one
one.map('two', function(val, key, config, next) {
two.process(val, next);
});// map keys from config
two to config one
one.addKey('two', two.keys);
console.log(one.keys);
//=> ['two.foo', 'two.bar', 'two.baz']
`Related projects
* assemble: Assemble is a powerful, extendable and easy to use static site generator for node.js. Used… more | homepage
* generate: Fast, composable, highly extendable project generator with a user-friendly and expressive API. | homepage
* templates: System for creating and managing template collections, and rendering templates with any node.js template engine.… more | homepage
* update: Easily keep anything in your project up-to-date by installing the updaters you want to use… more | homepage
* verb: Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… more | homepageRunning tests
Install dev dependencies:`sh
$ npm i -d && npm test
``*
_This file was generated by verb, v0.1.0, on February 23, 2016._