<commit_before>pageflow.AdjacentPages = pageflow.Object.extend({
  initialize: function(pages, scrollNavigator) {
    this.pages = pages;
    this.scrollNavigator = scrollNavigator;
  },

  of: function(page) {
    var result = [];
    var pages = this.pages();
    var nextPage = this.nextPage(page);

    if (nextPage.length) {
      result.push(nextPage.page('instance'));
    }

    _(page.linkedPages()).each(function(permaId) {
      var linkedPage = pages.filter('#' + permaId);

      if (linkedPage.length) {
        result.push(linkedPage.page('instance'));
      }
    }, this);

    return result;
  },

  nextPage: function(page) {
    var nextPage = this.scrollNavigator.getNextPage(page.element, this.pages());
    return nextPage.length && nextPage.page('instance');
  }
});<commit_msg>Fix adjacent page lookup for page preloading<commit_after>pageflow.AdjacentPages = pageflow.Object.extend({
  initialize: function(pages, scrollNavigator) {
    this.pages = pages;
    this.scrollNavigator = scrollNavigator;
  },

  of: function(page) {
    var result = [];
    var pages = this.pages();
    var nextPage = this.nextPage(page);

    if (nextPage) {
      result.push(nextPage);
    }

    _(page.linkedPages()).each(function(permaId) {
      var linkedPage = pages.filter('#' + permaId);

      if (linkedPage.length) {
        result.push(linkedPage.page('instance'));
      }
    }, this);

    return result;
  },

  nextPage: function(page) {
    var nextPage = this.scrollNavigator.getNextPage(page.element, this.pages());
    return nextPage.length && nextPage.page('instance');
  }
});
{'fraction_non_alphanumeric': 0.14773432650527624, 'fraction_numerical': 0.0, 'mean_word_length': 3.2986666666666666, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4667675', 'n_tokens_mistral': 510, 'n_tokens_neox': 497, 'n_words': 90}