sdk/src/third-party/easyXDM/easyXDM.js
function _createMethod(definition, method){
        var slice = Array.prototype.slice;
        
        return function(){
            var l = arguments.length, callback, message = {
                method: method
            };
            
            if (l > 0 && typeof arguments[l - 1] === "function") {
                //with callback, procedure
                if (l > 1 && typeof arguments[l - 2] === "function") {
                    // two callbacks, success and error
                    callback = {
                        success: arguments[l - 2],
                        error: arguments[l - 1]
                    };
                    message.params = slice.call(arguments, 0, l - 2);
                }
                else {
                    // single callback, success
                    callback = {
                        success: arguments[l - 1]
                    };
                    message.params = slice.call(arguments, 0, l - 1);
                }
                _callbacks["" + (++_callbackCounter)] = callback;
                message.id = _callbackCounter;
            }
            else {
                // no callbacks, a notification
                message.params = slice.call(arguments, 0);
            }
            if (definition.namedParams && message.params.length === 1) {
                message.params = message.params[0];
            }
            // Send the method request
            _send(message);
        };
    }
function _createMethod(definition, method){
        var slice = Array.prototype.slice;
        
        return function(){
            var l = arguments.length, callback, message = {
                method: method
            };
            
            if (l > 0 && typeof arguments[l - 1] === "function") {
                //with callback, procedure
                if (l > 1 && typeof arguments[l - 2] === "function") {
                    // two callbacks, success and error
                    callback = {
                        success: arguments[l - 2],
                        error: arguments[l - 1]
                    };
                    message.params = slice.call(arguments, 0, l - 2);
                }
                else {
                    // single callback, success
                    callback = {
                        success: arguments[l - 1]
                    };
                    message.params = slice.call(arguments, 0, l - 1);
                }
                _callbacks["" + (++_callbackCounter)] = callback;
                message.id = _callbackCounter;
            }
            else {
                // no callbacks, a notification
                message.params = slice.call(arguments, 0);
            }
            if (definition.namedParams && message.params.length === 1) {
                message.params = message.params[0];
            }
            // Send the method request
            _send(message);
        };
    }
function _createMethod ( definition , method ) { var slice = Array . prototype . slice ; return function ( ) { var l = arguments . length , callback , message = { method : method } ; if ( l > 0 && typeof arguments [ l - 1 ] === "function" ) { //with callback, procedure if ( l > 1 && typeof arguments [ l - 2 ] === "function" ) { // two callbacks, success and error callback = { success : arguments [ l - 2 ] , error : arguments [ l - 1 ] } ; message . params = slice . call ( arguments , 0 , l - 2 ) ; } else { // single callback, success callback = { success : arguments [ l - 1 ] } ; message . params = slice . call ( arguments , 0 , l - 1 ) ; } _callbacks [ "" + ( ++ _callbackCounter ) ] = callback ; message . id = _callbackCounter ; } else { // no callbacks, a notification message . params = slice . call ( arguments , 0 ) ; } if ( definition . namedParams && message . params . length === 1 ) { message . params = message . params [ 0 ] ; } // Send the method request _send ( message ) ; } ; }
Creates a method that implements the given definition
@private
@param {Object} The method configuration
@param {String} method The name of the method
@return {Function} A stub capable of proxying the requested method call
Creates a method that implements the given definition