pudge
v2.0.1
Published
simple node.js hook utility
Downloads
16
Readme
Pudge
install
npm install pudge --save
usage
var pudge = require('pudge');
pudge.register('AFTER_HOOKED', function rot(player) {
console.log('turned rot on');
return Promise.resolve();
});
pudge.register('AFTER_HOOKED', function dismemberr(player) {
console.log('eating', player.username);
return EatPlayer(player);
});
pudge.run('AFTER_HOOK', player).then(function() {
console.log('ultra kill')
});
// turned rot on
// eating dendi
// ultra kill
API
register(hookName, callback)
- register method to be run when hook happend
- callback will receive arguments that are passed in
run
orparallel
. - callback should return promise, so it's possible to know when hook is done
pudge.register('PUDGE_AWESOME_HOOK', function(arg1, arg2, arg3) {
// do something when hook is run
return Promise.resolve();
});
run(hookName, args...) -> Promise
run registred hooks one after another
pudge.run('PUDGE_AWESOME_HOOK', arg1, arg2, arg3).then(function() {
});
parallel(hookName, args...) -> Promise
run registred hooks in parallel
pudge.parallel('PUDGE_AWESOME_HOOK', arg1, arg2, arg3).then(function() {
});