<commit_before>var scrollSpy = {

  spyCallbacks: [],
  spySetState: [],

  mount: function (stateHandler, spyHandler) {
    this.addHandler('spySetState', stateHandler);
    this.addHandler('spyCallbacks', spyHandler);
  },

  currentPositionY: function () {
    var supportPageOffset = window.pageXOffset !== undefined;
    var isCSS1Compat = ((document.compatMode || "") === "CSS1Compat");
    return supportPageOffset ? window.pageYOffset : isCSS1Compat ?
            document.documentElement.scrollTop : document.body.scrollTop;
  },

  scrollHandler: function () {
    for(var i = 0; i < this.spyCallbacks.length; i++) {
      this.spyCallbacks[i](this.currentPositionY());
    }
  },

  hasHandlers: function() {
    return this.spyCallbacks.length || this.spySetState.length
  },

  addHandler: function(queueKey, handler) {
    if (handler && this[queueKey]) {
      if (document && !this.hasHandlers()) {
        this._scrollHandler = this.scrollHandler.bind(this)
        document.addEventListener('scroll', this._scrollHandler);
      }
      this[queueKey].push(handler);
    }
  },

  removeHandler: function(queueKey, handler) {
    var queue = this[queueKey] || [];
    var i = queue.indexOf(handler);
    if (i !== -1) {
      this[queueKey] = queue.splice(i, 1);
    }
    if (document && !this.hasHandlers()) {
      document.removeEventListener('scroll', this._scrollHandler);
    }
  },

  updateStates: function(){
    var length = this.spySetState.length;

    for(var i = 0; i < length; i++) {
      this.spySetState[i]();
    }
  },

  unmount: function (stateHandler, spyHandler) {
    this.removeHandler('spySetState', stateHandler);
    this.removeHandler('spyCallbacks', spyHandler);
  }
}

module.exports = scrollSpy;<commit_msg>Forgot how to splice X(<commit_after>var scrollSpy = {

  spyCallbacks: [],
  spySetState: [],

  mount: function (stateHandler, spyHandler) {
    this.addHandler('spySetState', stateHandler);
    this.addHandler('spyCallbacks', spyHandler);
  },

  currentPositionY: function () {
    var supportPageOffset = window.pageXOffset !== undefined;
    var isCSS1Compat = ((document.compatMode || "") === "CSS1Compat");
    return supportPageOffset ? window.pageYOffset : isCSS1Compat ?
            document.documentElement.scrollTop : document.body.scrollTop;
  },

  scrollHandler: function () {
    for(var i = 0; i < this.spyCallbacks.length; i++) {
      this.spyCallbacks[i](this.currentPositionY());
    }
  },

  hasHandlers: function() {
    return this.spyCallbacks.length || this.spySetState.length
  },

  addHandler: function(queueKey, handler) {
    if (handler && this[queueKey]) {
      if (document && !this.hasHandlers()) {
        this._scrollHandler = this.scrollHandler.bind(this)
        document.addEventListener('scroll', this._scrollHandler);
      }
      this[queueKey].push(handler);
    }
  },

  removeHandler: function(queueKey, handler) {
    var queue = this[queueKey] || [];
    var i = queue.indexOf(handler);
    if (i !== -1) {
      queue.splice(i, 1);
    }
    if (document && !this.hasHandlers()) {
      document.removeEventListener('scroll', this._scrollHandler);
    }
  },

  updateStates: function(){
    var length = this.spySetState.length;

    for(var i = 0; i < length; i++) {
      this.spySetState[i]();
    }
  },

  unmount: function (stateHandler, spyHandler) {
    this.removeHandler('spySetState', stateHandler);
    this.removeHandler('spyCallbacks', spyHandler);
  }
}

module.exports = scrollSpy;
{'fraction_non_alphanumeric': 0.14753631444033039, 'fraction_numerical': 0.003987467957846767, 'mean_word_length': 3.42875157629256, 'pattern_counts': {'":': 0, '<': 7, '<?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': '7530151', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1092, 'n_words': 198}