lib/backpack/index.js
function (cb, expect) {
        if (_.isFunction(cb) && cb.__normalised) {
            return meetExpectations(cb, expect);
        }

        var userback, // this var will be populated and returned
            // keep a reference of all initial callbacks sent by user
            callback = (_.isFunction(cb) && cb) || (_.isFunction(cb && cb.done) && cb.done),
            callbackError = _.isFunction(cb && cb.error) && cb.error,
            callbackSuccess = _.isFunction(cb && cb.success) && cb.success;

        // create master callback that calls these user provided callbacks
        userback = _.assign(function (err) {
            // if common callback is defined, call that
            callback && callback.apply(this, arguments);

            // for special error and success, call them if they are user defined
            if (err) {
                callbackError && callbackError.apply(this, arguments);
            }
            else {
                // remove the extra error param before calling success
                callbackSuccess && callbackSuccess.apply(this, (Array.prototype.shift.call(arguments), arguments));
            }
        }, _.isPlainObject(cb) && cb, { // override error, success and done
            error: function () {
                return userback.apply(this, arguments);
            },
            success: function () {
                // inject null to arguments and call the main callback
                userback.apply(this, (Array.prototype.unshift.call(arguments, null), arguments));
            },
            done: function () {
                return userback.apply(this, arguments);
            },
            __normalised: true
        });

        return meetExpectations(userback, expect);
    }
function (cb, expect) {
        if (_.isFunction(cb) && cb.__normalised) {
            return meetExpectations(cb, expect);
        }

        var userback, // this var will be populated and returned
            // keep a reference of all initial callbacks sent by user
            callback = (_.isFunction(cb) && cb) || (_.isFunction(cb && cb.done) && cb.done),
            callbackError = _.isFunction(cb && cb.error) && cb.error,
            callbackSuccess = _.isFunction(cb && cb.success) && cb.success;

        // create master callback that calls these user provided callbacks
        userback = _.assign(function (err) {
            // if common callback is defined, call that
            callback && callback.apply(this, arguments);

            // for special error and success, call them if they are user defined
            if (err) {
                callbackError && callbackError.apply(this, arguments);
            }
            else {
                // remove the extra error param before calling success
                callbackSuccess && callbackSuccess.apply(this, (Array.prototype.shift.call(arguments), arguments));
            }
        }, _.isPlainObject(cb) && cb, { // override error, success and done
            error: function () {
                return userback.apply(this, arguments);
            },
            success: function () {
                // inject null to arguments and call the main callback
                userback.apply(this, (Array.prototype.unshift.call(arguments, null), arguments));
            },
            done: function () {
                return userback.apply(this, arguments);
            },
            __normalised: true
        });

        return meetExpectations(userback, expect);
    }
function ( cb , expect ) { if ( _ . isFunction ( cb ) && cb . __normalised ) { return meetExpectations ( cb , expect ) ; } var userback , // this var will be populated and returned // keep a reference of all initial callbacks sent by user callback = ( _ . isFunction ( cb ) && cb ) || ( _ . isFunction ( cb && cb . done ) && cb . done ) , callbackError = _ . isFunction ( cb && cb . error ) && cb . error , callbackSuccess = _ . isFunction ( cb && cb . success ) && cb . success ; // create master callback that calls these user provided callbacks userback = _ . assign ( function ( err ) { // if common callback is defined, call that callback && callback . apply ( this , arguments ) ; // for special error and success, call them if they are user defined if ( err ) { callbackError && callbackError . apply ( this , arguments ) ; } else { // remove the extra error param before calling success callbackSuccess && callbackSuccess . apply ( this , ( Array . prototype . shift . call ( arguments ) , arguments ) ) ; } } , _ . isPlainObject ( cb ) && cb , { // override error, success and done error : function ( ) { return userback . apply ( this , arguments ) ; } , success : function ( ) { // inject null to arguments and call the main callback userback . apply ( this , ( Array . prototype . unshift . call ( arguments , null ) , arguments ) ) ; } , done : function ( ) { return userback . apply ( this , arguments ) ; } , __normalised : true } ) ; return meetExpectations ( userback , expect ) ; }
accept the callback parameter and convert it into a consistent object interface

@param {Function|Object} cb
@param {Array} [expect=]
@returns {Object}

@todo - write tests
accept the callback parameter and convert it into a consistent object interface