Naboo's Podracing Misadventure

    pudge

    2.0.1 • Public • Published

    Pudge

    Build Status

    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 or parallel.
    • 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() {
     
    });

    Install

    npm i pudge

    DownloadsWeekly Downloads

    13

    Version

    2.0.1

    License

    MIT

    Unpacked Size

    14.3 kB

    Total Files

    7

    Last publish

    Collaborators

    • avatar