<commit_before>// it will have to wait for the first request :<
/**
 *
 * @param {Promise} promise - Promise that returns a {@link PaginatedResourceWrapper}
 * @param {?Number} [start=1] - Start page
 * @param {?Number} [stop] - Stop page
 * @returns {Promise}
 */
export function getPaginatedRange(promise, start = 1, stop) {
  return promise.then(page => {
    const out = page.data;
    const promises = [];

    // Handle defaults
    start = start || page.page;
    stop = stop || page.pageCount;

    return new Promise((resolve, reject) => {
      for (let i = start + 1; i <= stop; i++) {
        promises.push(page.get(i));
      }

      Promise.all(promises).then(rows => {
        rows.map(x => x.data).forEach(out.push);

        resolve(out);
      }, reject);
    });
  });
}<commit_msg>getPaginatedRange docs<commit_after>/**
 * Get all the pages from a {@link PaginatedResourceListing} or a range
 * @param {Promise<PaginatedResourceListing>|PaginatedResourceListing} page - Promise that returns a {@link PaginatedResourceWrapper}
 * @param {?Number} [start=1] - Start page
 * @param {?Number} [stop] - Stop page
 * @returns {Promise<Array<ResourceBase>>} - Resolves with an {@link Array} containing {@link PaginatedResourceListing} instance and rejects with {@link ApiError}
 * @example
 * const first = api.users.list();
 *
 * getPaginatedRange(promise).then(data => {
 *    data.map(row => `[${row.id}] ${row.name}`) // We just want the names
 *        .forEach(console.log) // Log the names and ids of every user
 * })
 */
export function getPaginatedRange(page, start = 1, stop) {
  // Resolve promise if any
  if (page instanceof Promise) {
    return page.then(res => getPaginatedRange(res, start, stop));
  }

  const out = page.data;
  const promises = [];

  // Handle defaults
  start = start || page.page;
  stop = stop || page.pageCount;

  if (start === page.page) {
    start++;
  }

  return new Promise((resolve, reject) => {
    // Get all pages
    for (let i = start; i <= stop; i++) {
      promises.push(page.get(i));
    }

    // Resolve
    Promise.all(promises).then(rows => {
      rows.map(x => x.data).forEach(out.push);

      resolve(out);
    }, reject);
  });
}
{'fraction_non_alphanumeric': 0.15739484396200815, 'fraction_numerical': 0.002261420171867933, 'mean_word_length': 3.088724584103512, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2184990', 'n_tokens_mistral': 705, 'n_tokens_neox': 694, 'n_words': 197}