<commit_before>'use strict';

var _ = require('lodash');

function initWatchVal(){}

function Scope() {
  this.$$watchers = [];
  this.$$lastDirtyWatch = null;
}

Scope.prototype.$watch = function(watchFn, listenerFn, valueEq) {

  var watcher = {
    watchFn: watchFn,
    listenerFn: listenerFn || function(){},
    valueEq: !!valueEq,
    last: initWatchVal
  };

  this.$$watchers.push(watcher);
  this.$$lastDirtyWatch = null;
};

Scope.prototype.$$digestOnce = function() {
  var self = this;

  var newValue, oldValue, dirty;

  _.forEach(this.$$watchers, function(watcher) {
    newValue = watcher.watchFn(self);
    oldValue = watcher.last;

    if(!self.$$areEqual(newValue, oldValue, watcher.valueEq)) {
      self.$$lastDirtyWatch = watcher;
      watcher.last = (watcher.valueEq ? _.cloneDeep(newValue) : newValue);
      watcher.listenerFn(newValue,
        (oldValue === initWatchVal ? newValue : oldValue),
        self);
      dirty = true;
    } else if(self.$$lastDirtyWatch === watcher){
      return false;
    }
  });
  return dirty;
};

Scope.prototype.$digest = function(){
  var self = this;

  var ttl = 10;
  var dirty;
  this.$$lastDirtyWatch = null;
  do {
    dirty = this.$$digestOnce();
    if(dirty && !(ttl--)){
      throw "10 digest iterations reached";
    }
  } while(dirty);
};

Scope.prototype.$$areEqual = function(newValue, oldValue, valueEq) {
  if(valueEq){
    return _.isEqual(newValue, oldValue);
  } else {
    return newValue === oldValue;
  }
}

module.exports = Scope;<commit_msg>Added missing semicolon<commit_after>'use strict';

var _ = require('lodash');

function initWatchVal(){}

function Scope() {
  this.$$watchers = [];
  this.$$lastDirtyWatch = null;
}

Scope.prototype.$watch = function(watchFn, listenerFn, valueEq) {

  var watcher = {
    watchFn: watchFn,
    listenerFn: listenerFn || function(){},
    valueEq: !!valueEq,
    last: initWatchVal
  };

  this.$$watchers.push(watcher);
  this.$$lastDirtyWatch = null;
};

Scope.prototype.$$digestOnce = function() {
  var self = this;

  var newValue, oldValue, dirty;

  _.forEach(this.$$watchers, function(watcher) {
    newValue = watcher.watchFn(self);
    oldValue = watcher.last;

    if(!self.$$areEqual(newValue, oldValue, watcher.valueEq)) {
      self.$$lastDirtyWatch = watcher;
      watcher.last = (watcher.valueEq ? _.cloneDeep(newValue) : newValue);
      watcher.listenerFn(newValue,
        (oldValue === initWatchVal ? newValue : oldValue),
        self);
      dirty = true;
    } else if(self.$$lastDirtyWatch === watcher){
      return false;
    }
  });
  return dirty;
};

Scope.prototype.$digest = function(){
  var self = this;

  var ttl = 10;
  var dirty;
  this.$$lastDirtyWatch = null;
  do {
    dirty = this.$$digestOnce();
    if(dirty && !(ttl--)){
      throw "10 digest iterations reached";
    }
  } while(dirty);
};

Scope.prototype.$$areEqual = function(newValue, oldValue, valueEq) {
  if(valueEq){
    return _.isEqual(newValue, oldValue);
  } else {
    return newValue === oldValue;
  }
};

module.exports = Scope;
{'fraction_non_alphanumeric': 0.155873739017247, 'fraction_numerical': 0.0026033192320208264, 'mean_word_length': 3.3726884779516357, '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': '3544411', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1007, 'n_words': 211}