<commit_before>class Scroll {

  constructor(element) {
    if (typeof window.pageYOffset !== 'undefined') {
      this.scrollCalc = function scrollCal() {
        return [window.pageXOffset, window.pageYOffset];
      };
    } else if (typeof document.documentElement.scrollTop !== 'undefined' &&
    document.documentElement.scrollTop > 0) {
      this.scrollCalc = function scrollCalc() {
        return [document.documentElement.scrollLeft, document.documentElement.scrollTop];
      };
    } else if (typeof document.body.scrollTop !== 'undefined') {
      this.scrollCalc = function scrollCalc() {
        return [document.body.scrollLeft, document.body.scrollTop];
      };
    } else {
      throw new Error('Not Supported');
    }

    this.contentElements = document.getElementsByClassName(element);

    if (this.contentElements.length === 0) {
      throw new Error("No Elements Found");
    } else {
      this.upperContentBound = this.contentElements[0];
      this.lowerContentBound = this.contentElements[this.contentElements.length - 1];
      this.update();
    }
  }

  update() {
    [this.xPos, this.yPos] = this.scrollCalc();
    this.elementInViewport = this.elementsInViewport();
  }

  elementsInViewport() {
    const viewportChecks = Array.from(this.contentElements, (el) => {
      const rect = el.getBoundingClientRect();
      return (
          rect.top >= 0 &&
          rect.left >= 0 &&
          rect.bottom <= (window.innerHeight || document.documentElement
              .clientHeight) &&
          rect.right <= (window.innerWidth || document.documentElement
              .clientWidth)
      );
    });
    return viewportChecks.some(x => x === true);<commit_msg>use promise<commit_after>class Scroll {

  constructor(element) {
    if (typeof window.pageYOffset !== 'undefined') {
      this.scrollCalc = function scrollCal() {
        return [window.pageXOffset, window.pageYOffset];
      };
    } else if (typeof document.documentElement.scrollTop !== 'undefined' &&
    document.documentElement.scrollTop > 0) {
      this.scrollCalc = function scrollCalc() {
        return [document.documentElement.scrollLeft, document.documentElement.scrollTop];
      };
    } else if (typeof document.body.scrollTop !== 'undefined') {
      this.scrollCalc = function scrollCalc() {
        return [document.body.scrollLeft, document.body.scrollTop];
      };
    } else {
      throw new Error('Not Supported');
    }

    this.setContentElements().then(() => {
      this.update();
    }).catch((error) =>
      throw new Error(error);
    });
  }

  setContentElements() {
    return new Promise(function(resolve, reject) {
      this.elements = document.getElementsByClassName(element);
      if (this.elements.length === 0) {
        reject('No Elements Found');
      } else {
        this.upperContentBound = this.elements[0];
        this.lowerContentBound = this.elements[this.elements.length - 1];
        resolve();
      }
    });
  }

  update() {
    [this.xPos, this.yPos] = this.scrollCalc();
    this.elementInViewport = this.elementsInViewport();
  }

  elementsInViewport() {
    const viewportChecks = Array.from(this.elements, (el) => {
      const rect = el.getBoundingClientRect();
      return (
          rect.top >= 0 &&
          rect.left >= 0 &&
          rect.bottom <= (window.innerHeight || document.documentElement
              .clientHeight) &&
          rect.right <= (window.innerWidth || document.documentElement
              .clientWidth)
      );
    });
    return viewportChecks.some(x => x === true);
{'fraction_non_alphanumeric': 0.13447022644674309, 'fraction_numerical': 0.0033547665641599105, 'mean_word_length': 2.688659793814433, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '1167837', 'n_tokens_mistral': 1025, 'n_tokens_neox': 1000, 'n_words': 189}