before
before decorator factory
Installation
npm install before
Example
var before = require('before');
var speak = {
greeting: 'welcome',
greet: function(a, b, fn){
fn(null, a + ' ' + b);
}
};
speak.before = before(speak);
speak.before('greet', function(args, fn){
args[0] = args[0] + ' to this wonderful';
fn();
});
speak.before('greet', function(args, fn){
args[0] = args[0] + ', ' + this.greeting;
fn();
});
speak.greet('Human', 'world!', function(err, result){
console.log(result);
});
API
before(context)
Captures context
to be used by decorator.
before(method, outer)
Decorates method
using outer
.
outer
is called with (args, fn)
to allow
arguments mutation.
License
MIT