Comparing version 1.0.1 to 1.0.3
@@ -42,3 +42,3 @@ /*───────────────────────────────────────────────────────────────────────────*\ | ||
if (isModule(file)) { | ||
resolve(require(file), callback); | ||
resolve(require(file), file, callback); | ||
return; | ||
@@ -55,3 +55,3 @@ } | ||
data = JSON.parse(data); | ||
resolve(data, callback); | ||
resolve(data, file, callback); | ||
} catch (err) { | ||
@@ -66,2 +66,2 @@ callback(err); | ||
}; | ||
}; |
@@ -139,5 +139,10 @@ /*───────────────────────────────────────────────────────────────────────────*\ | ||
*/ | ||
resolve: function resolve(data, callback) { | ||
resolve: function resolve(data, filename, callback) { | ||
var self, tasks, handler; | ||
if (!callback) { | ||
callback = filename; | ||
filename = null; | ||
} | ||
self = this; | ||
@@ -150,3 +155,3 @@ | ||
tasks = data.map(function (val) { | ||
return resolve.bind(self, val); | ||
return resolve.bind(self, val, filename); | ||
}); | ||
@@ -157,3 +162,3 @@ | ||
Object.keys(data).forEach(function (key) { | ||
tasks[key] = resolve.bind(self, data[key]); | ||
tasks[key] = resolve.bind(self, data[key], filename); | ||
}); | ||
@@ -181,2 +186,4 @@ } | ||
if (handler.length < 2) { | ||
// If the handler is single argument, expect its return value to be useful, | ||
// so we wrap it up in continuation-passing style | ||
return function wrapper(input, done) { | ||
@@ -198,4 +205,6 @@ var data, error; | ||
tasks.unshift(function init(done) { | ||
tasks.unshift(tasks[0].length == 2 ? function init(done) { | ||
done(null, data); | ||
} : function init(done) { | ||
done(null, data, filename); | ||
}); | ||
@@ -202,0 +211,0 @@ |
{ | ||
"name": "shortstop", | ||
"version": "1.0.1", | ||
"version": "1.0.3", | ||
"description": "Enable use of protocols (such as file:, buffer:, or method:) in configuration files.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,3 +0,8 @@ | ||
# shortstop | ||
shortstop | ||
========= | ||
Lead Maintainer: [Poornima Venkat](https://github.com/pvenkatakrishnan/) | ||
[![Build Status](https://travis-ci.org/krakenjs/shortstop.svg?branch=master)](https://travis-ci.org/krakenjs/shortstop) | ||
Sometimes JSON just isn't enough for configuration needs. Occasionally it would be nice to use arbitrary types as values, | ||
@@ -7,4 +12,2 @@ but JSON is necessarily a subset of all available JS types. `shortstop` enables the use of protocols and handlers to | ||
[![Build Status](https://travis-ci.org/krakenjs/shortstop.png?branch=master)](https://travis-ci.org/krakenjs/shortstop) | ||
```javascript | ||
@@ -11,0 +14,0 @@ var fs = require('fs'); |
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
19496
215
149
1