Do request

@param {Object} reqOpts the request options
@return {Promise}
function doRequest(reqOpts) {
    reqOpts = Object.assign({}, reqOpts);
    if (currRequestNum >= requestMaxNum) {
        return new Promise((resolve, reject) => {
            waitingQueues.push({
                options: reqOpts,
                resolve,
                reject
            });
        });
    }

    currRequestNum++;

    let rawComplete = reqOpts.complete;
    reqOpts.complete = function (...args) {
        currRequestNum--;

        rawComplete && rawComplete(...args);

        if (!waitingQueues.length) {
            return;
        }

        let processReqInfo = waitingQueues.shift();
        doRequest(processReqInfo.options).then(
            res => processReqInfo.resolve(res),
            err => processReqInfo.reject(err)
        );
    };

    return rawRequest(reqOpts);
}