Package Exports
- hookable
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (hookable) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Hookable
Enable hookable functions on an object.
Installation
Works with Express 3.0.x
$ npm install hookable
Usage
Hookable adds functionality to wrap a function with before
and after
hooks
// require it
var hookable = require('hookable'),
myObject = {
add: function (a, b) {
return a + b;
}
};
// use it on your object
hookable(myObject);
// enable hooking on your objects function
myObject.add = myObject.hook('add', myObject.add);
// define a function to fire before the original
myObject.before('add', function (a, b) {
console.log('.add is about to fire with ' + a + ' and ' + b);
});
// define a function to fire after the original
myObject.after('add', function (a, b) {
console.log('.add has fired with ' + a + ' and ' + b);
});
To Do
- Make hooks fire asynchronously
- Write tests