Comparing version 0.3.0 to 0.3.1
21
index.js
const _ = require('lodash'); | ||
const getobject = require('getobject'); | ||
const EventEmitter = require('events').EventEmitter; | ||
@@ -101,6 +102,20 @@ // exported object | ||
expander.walk = function (config, lookup, key) { | ||
var path = []; | ||
var nodes = lookup.split('.'); | ||
var merges = [config.get(key)]; | ||
nodes.forEach(function (node) { | ||
path.push(node); | ||
merges.push(config.get(path.concat(key).join('.'))); | ||
}); | ||
return _.merge.apply(null, merges); | ||
}; | ||
// provide a getter/setter interface for expander | ||
// this is so ugly. | ||
expander.interface = function (data) { | ||
var emitter = new EventEmitter(); | ||
var API = function (prop, value) { | ||
if (arguments.length === 2) { | ||
emitter.emit('set', prop, value); | ||
return getobject.set(data, prop, value); | ||
@@ -111,3 +126,7 @@ } else { | ||
}; | ||
['get', 'getRaw', 'set', 'process'].forEach(function (method) { | ||
API.set = function (prop, value) { | ||
return API(prop, value); | ||
}; | ||
API.on = emitter.on.bind(emitter); | ||
['get', 'getRaw', 'process'].forEach(function (method) { | ||
API[method] = expander[method].bind(null, data); | ||
@@ -114,0 +133,0 @@ }); |
{ | ||
"name": "expander", | ||
"description": "Expand template strings in declarative configurations.", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"homepage": "https://github.com/tkellen/expander", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -83,2 +83,3 @@ # expander [![Build Status](https://secure.travis-ci.org/tkellen/node-expander.png?branch=master)](http://travis-ci.org/tkellen/node-expander) | ||
* 2014-02-11 - v0.3.1 - interface emits events on set | ||
* 2014-02-10 - v0.3.0 - support a getter/setter api | ||
@@ -85,0 +86,0 @@ * 2013-12-15 - v0.2.2 - support auto expansion of functions |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9420
120
89
0
735