Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

expander

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expander - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

10

lib/expander.js

@@ -34,2 +34,8 @@ /*

// set a heuristic indicating the method should be expanded
expander.fn = function(method) {
method.__expanderFn__ = true;
return method;
};
// recursively expand a string until it doesn't contain any template strings

@@ -70,3 +76,5 @@ expander.stringExpand = function (data, lookup) {

expander.process = function (data, lookup) {
if(_.isString(lookup)) {
if(_.isFunction(lookup) && lookup.__expanderFn__ === true) {
return lookup.call(this, data);
} else if(_.isString(lookup)) {
return expander.stringExpand(data, lookup);

@@ -73,0 +81,0 @@ } else if(_.isArray(lookup)) {

2

package.json
{
"name": "expander",
"description": "Expand template strings in declarative configurations.",
"version": "0.2.1",
"version": "0.2.2",
"homepage": "https://github.com/tkellen/expander",

@@ -6,0 +6,0 @@ "author": {

@@ -8,3 +8,3 @@ # expander [![Build Status](https://secure.travis-ci.org/tkellen/node-expander.png?branch=master)](http://travis-ci.org/tkellen/node-expander)

```js
var expander = require('expander');
var expander = require('./lib/expander');

@@ -27,18 +27,10 @@ var data = {

interpolatedRecursiveRef: 'test <%= keyRef %>',
_key: 'value',
_keyRef: '${_key}',
_recursiveKeyRef: '${_keyRef}',
_arrayRef: ['test', '${_key}'],
_recursiveArrayRef: ['test', '${_arrayRef}'],
_obj: {
_keyRef: '${_key}',
_recursiveKeyRef: '${_keyRef}',
_arrayRef: ['test', '${_key}'],
_recursiveArrayRef: ['test', '${_arrayRef}']
},
_dotRef: '${ _obj._keyRef }',
_objRef: '${_obj}',
_interpolated: 'test ${ _key}',
_interpolatedRecursiveRef: 'test ${_keyRef }'
methodRef: expander.fn(function (config) {
// config is the entire config
return config.key;
}),
methodRefContext: expander.fn(function (config) {
// this is a reference to expander
return this.get(config, 'keyRef');
})
};

@@ -64,2 +56,4 @@

expander.get(data, 'interpolatedRecursiveRef'); // test value
expander.get(data, 'methodRef'); // value
expander.get(data, 'methodRefContext'); // value
```

@@ -69,4 +63,5 @@

* 2013-12-15 - v0.2.2 - support auto expansion of functions
* 2013-11-21 - v0.2.1 - support ${value} strings
* 2013-11-08 - v0.2.0 - correctly handle recursively interpolated values
* 2013-11-05 - v0.1.0 - initial release
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc