proxyfn
v0.1.0
Published
Add **use** `pre-processing` functionality to any function.
Downloads
2
Readme
proxyfn
Add use
pre-processing
functionality to any function.
Install
$ npm install proxyfn --save
Usage
var proxyfn = require('proxyfn');
var get = proxyfn(http.get);
get.use(function (options, callback, next) {
if (options === 'http://www.google.com') {
return callback({ statusCode: 404 });
}
return next(null, options, callback);
});
get('http://www.google.com', function (res) {
assert.equal(res.statusCode, 404);
});
get('http://www.google.co.uk', function (res) {
assert.equal(res.statusCode, 200);
});
License
MIT © Colin Milhench