code: function loop(fn, retries) {
      /**
       * Retries fn through the loop after the delay (ms).
       * If all retries have been exhausted the err is returned
       * as the reason for rejection of the promise.
       *
       * @param err
       *
       * @returns {Promise}
       */
      function retry (err) {
        if (retries < maxRetries) {
          return Bluebird
            .delay(ms)
            .then(function() {
              return loop(fn, retries + 1);
            });
        }
  
        return Bluebird.reject(err);
      }
  
      // Resolve non-promise and promise returns of fn()
      // Retry on any caught errors.
      return Bluebird.resolve(fn()).catch(retry);
    }
docs: jshint ignore:line 
  Retry loop
  
  @param fn
  @param retries
  @returns {*}