function Client (context) {

    var reqHandlers = [sendRequest], resHandlers = [];

    if (!isObject(context)) {
        context = null;
    }

    function Client(request) {
        while (reqHandlers.length) {

            var handler = reqHandlers.pop();

            if (isFunction(handler)) {

                var response = (void 0), next = (void 0);

                response = handler.call(context, request, function (val) { return next = val; }) || next;

                if (isObject(response)) {
                    return new PromiseObj(function (resolve, reject) {

                        resHandlers.forEach(function (handler) {
                            response = when(response, function (response) {
                                return handler.call(context, response) || response;
                            }, reject);
                        });

                        when(response, resolve, reject);

                    }, context);
                }

                if (isFunction(response)) {
                    resHandlers.unshift(response);
                }

            } else {
                warn(("Invalid interceptor of type " + (typeof handler) + ", must be a function"));
            }
        }
    }

    Client.use = function (handler) {
        reqHandlers.push(handler);
    };

    return Client;
}
function Client (context) {

    var reqHandlers = [sendRequest], resHandlers = [];

    if (!isObject(context)) {
        context = null;
    }

    function Client(request) {
        while (reqHandlers.length) {

            var handler = reqHandlers.pop();

            if (isFunction(handler)) {

                var response = (void 0), next = (void 0);

                response = handler.call(context, request, function (val) { return next = val; }) || next;

                if (isObject(response)) {
                    return new PromiseObj(function (resolve, reject) {

                        resHandlers.forEach(function (handler) {
                            response = when(response, function (response) {
                                return handler.call(context, response) || response;
                            }, reject);
                        });

                        when(response, resolve, reject);

                    }, context);
                }

                if (isFunction(response)) {
                    resHandlers.unshift(response);
                }

            } else {
                warn(("Invalid interceptor of type " + (typeof handler) + ", must be a function"));
            }
        }
    }

    Client.use = function (handler) {
        reqHandlers.push(handler);
    };

    return Client;
}
function Client ( context ) { var reqHandlers = [ sendRequest ] , resHandlers = [ ] ; if ( ! isObject ( context ) ) { context = null ; } function Client ( request ) { while ( reqHandlers . length ) { var handler = reqHandlers . pop ( ) ; if ( isFunction ( handler ) ) { var response = ( void 0 ) , next = ( void 0 ) ; response = handler . call ( context , request , function ( val ) { return next = val ; } ) || next ; if ( isObject ( response ) ) { return new PromiseObj ( function ( resolve , reject ) { resHandlers . forEach ( function ( handler ) { response = when ( response , function ( response ) { return handler . call ( context , response ) || response ; } , reject ) ; } ) ; when ( response , resolve , reject ) ; } , context ) ; } if ( isFunction ( response ) ) { resHandlers . unshift ( response ) ; } } else { warn ( ( "Invalid interceptor of type " + ( typeof handler ) + ", must be a function" ) ) ; } } } Client . use = function ( handler ) { reqHandlers . push ( handler ) ; } ; return Client ; }
Base client.
Base client .
A client that can be used to send requests to the server