lib/client.js
function(methodName, args) {
        var method   = this.spec.methods[methodName];
        if (method.deprecated === true)
            console.warn('Method '+ methodName + ' is deprecated.')
        var callback = args.pop(); // callback is always at the end
        var middleware = args[0];
        var params   = null;
        var payload  = null;
        var index = 0;
        if (typeof middleware != 'function') {
            params = args[0];
            middleware = null;
        } else {
            params = args[1];
            index = 1;
        }
        if (args.length > 1) {
            payload = args[index + 1];
        } else {
            if (method.required_params.length == 0
                && method.optional_params.length == 0) {
                payload = args[index];
                params = null;
            }
        }
        if (this._isValidCall(method, callback, params, payload)) {
            var request = this._createRequest(method, params, payload);
            var middlewares = this.middlewares.slice(0);
            if (middleware !== null) middlewares.push({cond: function() { return true; }, fun: middleware});
            this._callRequestMiddlewares(middlewares, method, request, [], callback);
        }
    }
function(methodName, args) {
        var method   = this.spec.methods[methodName];
        if (method.deprecated === true)
            console.warn('Method '+ methodName + ' is deprecated.')
        var callback = args.pop(); // callback is always at the end
        var middleware = args[0];
        var params   = null;
        var payload  = null;
        var index = 0;
        if (typeof middleware != 'function') {
            params = args[0];
            middleware = null;
        } else {
            params = args[1];
            index = 1;
        }
        if (args.length > 1) {
            payload = args[index + 1];
        } else {
            if (method.required_params.length == 0
                && method.optional_params.length == 0) {
                payload = args[index];
                params = null;
            }
        }
        if (this._isValidCall(method, callback, params, payload)) {
            var request = this._createRequest(method, params, payload);
            var middlewares = this.middlewares.slice(0);
            if (middleware !== null) middlewares.push({cond: function() { return true; }, fun: middleware});
            this._callRequestMiddlewares(middlewares, method, request, [], callback);
        }
    }
function ( methodName , args ) { var method = this . spec . methods [ methodName ] ; if ( method . deprecated === true ) console . warn ( 'Method ' + methodName + ' is deprecated.' ) var callback = args . pop ( ) ; // callback is always at the end var middleware = args [ 0 ] ; var params = null ; var payload = null ; var index = 0 ; if ( typeof middleware != 'function' ) { params = args [ 0 ] ; middleware = null ; } else { params = args [ 1 ] ; index = 1 ; } if ( args . length > 1 ) { payload = args [ index + 1 ] ; } else { if ( method . required_params . length == 0 && method . optional_params . length == 0 ) { payload = args [ index ] ; params = null ; } } if ( this . _isValidCall ( method , callback , params , payload ) ) { var request = this . _createRequest ( method , params , payload ) ; var middlewares = this . middlewares . slice ( 0 ) ; if ( middleware !== null ) middlewares . push ( { cond : function ( ) { return true ; } , fun : middleware } ) ; this . _callRequestMiddlewares ( middlewares , method , request , [ ] , callback ) ; } }
args is an array with some possibilities
middleware, params, payload, callback
middleware, payload, callback
middleware, params, callback
middleware, callback
params, payload, callback
payload, callback
params, callback
callback
args is an array with some possibilities middleware params payload callback middleware payload callback middleware params callback middleware callback params payload callback payload callback params callback callback