<commit_before>'use strict';

var makeRequest = require('./makeRequest');
var utils = require('./utils');

function makeAutoPaginationMethods(self, requestArgs, spec, firstPagePromise) {
  var promiseCache = {currentPromise: null};
  var listPromise = firstPagePromise;
  var i = 0;

  function iterate(listResult) {
    if (!(listResult && listResult.data && typeof listResult.data.length === 'number')) {
      throw Error('Unexpected: Stripe API response does not have a well-formed `data` array.');
    }

    if (i < listResult.data.length) {
      var value = listResult.data[i];
      i += 1;
      return {value: value, done: false};
    } else if (listResult.has_more) {
      // Reset counter, request next page, and recurse.
      i = 0;
      var lastId = getLastId(listResult);
      listPromise = makeRequest(self, requestArgs, spec, {starting_after: lastId});
      return listPromise.then(iterate);
    }
    return {value: undefined, done: true};
  }

  function asyncIteratorNext() {
    return memoizedPromise(promiseCache, function(resolve, reject) {
      return listPromise
        .then(iterate)
        .then(resolve)
        .catch(reject);
    });
  }

  var autoPagingEach = makeAutoPagingEach(asyncIteratorNext);
  var autoPagingToArray = makeAutoPagingToArray(autoPagingEach);

  const autoPaginationMethods = {
    autoPagingEach: autoPagingEach,
    autoPagingToArray: autoPagingToArray,

    // Async iterator functions:
    next: asyncIteratorNext,
    return: function() {
      // This is required for `break`.
      return {};
    },
    [getAsyncIteratorSymbol()]: function() {<commit_msg>Remove a const<commit_after>'use strict';

var makeRequest = require('./makeRequest');
var utils = require('./utils');

function makeAutoPaginationMethods(self, requestArgs, spec, firstPagePromise) {
  var promiseCache = {currentPromise: null};
  var listPromise = firstPagePromise;
  var i = 0;

  function iterate(listResult) {
    if (!(listResult && listResult.data && typeof listResult.data.length === 'number')) {
      throw Error('Unexpected: Stripe API response does not have a well-formed `data` array.');
    }

    if (i < listResult.data.length) {
      var value = listResult.data[i];
      i += 1;
      return {value: value, done: false};
    } else if (listResult.has_more) {
      // Reset counter, request next page, and recurse.
      i = 0;
      var lastId = getLastId(listResult);
      listPromise = makeRequest(self, requestArgs, spec, {starting_after: lastId});
      return listPromise.then(iterate);
    }
    return {value: undefined, done: true};
  }

  function asyncIteratorNext() {
    return memoizedPromise(promiseCache, function(resolve, reject) {
      return listPromise
        .then(iterate)
        .then(resolve)
        .catch(reject);
    });
  }

  var autoPagingEach = makeAutoPagingEach(asyncIteratorNext);
  var autoPagingToArray = makeAutoPagingToArray(autoPagingEach);

  var autoPaginationMethods = {
    autoPagingEach: autoPagingEach,
    autoPagingToArray: autoPagingToArray,

    // Async iterator functions:
    next: asyncIteratorNext,
    return: function() {
      // This is required for `break`.
      return {};
    },
    [getAsyncIteratorSymbol()]: function() {
{'fraction_non_alphanumeric': 0.11750230698246693, 'fraction_numerical': 0.001845585973546601, 'mean_word_length': 3.4005412719891748, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4080992', 'n_tokens_mistral': 959, 'n_tokens_neox': 938, 'n_words': 246}