lib/Request.js
function () {
    var self = this;

    if (this.counted) {
      return this.getRequestCount()
        .then(function (count) {
          count = count || 0;
          //如果请求数超过限制则 setTimeout 排队
          if (count >= config.requestLimit) {
            return Promise.delay(config.requestTimeout).then(self.onBeforeHandle);
          }
          return count;
        })
        .then(increment)
        .then(this.saveRequestCount);
    }

    return Promise.resolve();
  }
function () {
    var self = this;

    if (this.counted) {
      return this.getRequestCount()
        .then(function (count) {
          count = count || 0;
          //如果请求数超过限制则 setTimeout 排队
          if (count >= config.requestLimit) {
            return Promise.delay(config.requestTimeout).then(self.onBeforeHandle);
          }
          return count;
        })
        .then(increment)
        .then(this.saveRequestCount);
    }

    return Promise.resolve();
  }
请求前的操作