proxyfn

0.1.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i proxyfn

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • cmilhench