lib/backpack/index.js
function (flags, callback, args, ms) {
        var status = {},
            sealed;

        // ensure that the callback times out after a while
        callback = backpack.timeback(callback, ms, null, function () {
            sealed = true;
        });

        return function (err, flag, value) {
            if (sealed) { return; } // do  not proceed of it is sealed
            status[flag] = value;

            if (err) { // on error we directly call the callback and seal subsequent calls
                sealed = true;
                status = null;
                callback.call(status, err);

                return;
            }

            // if any flag is not defined, we exit. when all flags hold a value, we know that the end callback has to be
            // executed.
            for (var i = 0, ii = flags.length; i < ii; i++) {
                if (!status.hasOwnProperty(flags[i])) { return; }
            }

            sealed = true;
            status = null;
            callback.apply(status, args);
        };
    }
function (flags, callback, args, ms) {
        var status = {},
            sealed;

        // ensure that the callback times out after a while
        callback = backpack.timeback(callback, ms, null, function () {
            sealed = true;
        });

        return function (err, flag, value) {
            if (sealed) { return; } // do  not proceed of it is sealed
            status[flag] = value;

            if (err) { // on error we directly call the callback and seal subsequent calls
                sealed = true;
                status = null;
                callback.call(status, err);

                return;
            }

            // if any flag is not defined, we exit. when all flags hold a value, we know that the end callback has to be
            // executed.
            for (var i = 0, ii = flags.length; i < ii; i++) {
                if (!status.hasOwnProperty(flags[i])) { return; }
            }

            sealed = true;
            status = null;
            callback.apply(status, args);
        };
    }
function ( flags , callback , args , ms ) { var status = { } , sealed ; // ensure that the callback times out after a while callback = backpack . timeback ( callback , ms , null , function ( ) { sealed = true ; } ) ; return function ( err , flag , value ) { if ( sealed ) { return ; } // do  not proceed of it is sealed status [ flag ] = value ; if ( err ) { // on error we directly call the callback and seal subsequent calls sealed = true ; status = null ; callback . call ( status , err ) ; return ; } // if any flag is not defined, we exit. when all flags hold a value, we know that the end callback has to be // executed. for ( var i = 0 , ii = flags . length ; i < ii ; i ++ ) { if ( ! status . hasOwnProperty ( flags [ i ] ) ) { return ; } } sealed = true ; status = null ; callback . apply ( status , args ) ; } ; }
Convert a callback into a function that is called multiple times and the callback is actually called when a set
of flags are set to true

@param {Array} flags
@param {Function} callback
@param {Array} args
@param {Number} ms
@returns {Function}
Convert a callback into a function that is called multiple times and the callback is actually called when a set of flags are set to true