api-chain.js
function(name, method) {
        API.prototype[name] = function() {
            var api = this;
            var args = Array.prototype.slice.call(arguments);
            this.chain(function(next) {
                var cargs = [].slice.call(arguments);

                cargs = args.concat(cargs);

                // args.push(next);
                method.apply(api, cargs);
            });
            return this;
        };
        return this;
    }
function(name, method) {
        API.prototype[name] = function() {
            var api = this;
            var args = Array.prototype.slice.call(arguments);
            this.chain(function(next) {
                var cargs = [].slice.call(arguments);

                cargs = args.concat(cargs);

                // args.push(next);
                method.apply(api, cargs);
            });
            return this;
        };
        return this;
    }
function ( name , method ) { API . prototype [ name ] = function ( ) { var api = this ; var args = Array . prototype . slice . call ( arguments ) ; this . chain ( function ( next ) { var cargs = [ ] . slice . call ( arguments ) ; cargs = args . concat ( cargs ) ; // args.push(next); method . apply ( api , cargs ) ; } ) ; return this ; } ; return this ; }
add a method to the prototype
add a method to the prototype