<commit_before>module.exports = {
  compare: compare,
  expressions: function (cfg, pattern, iterator) {
    expressionWalker(cfg.body, function(node) {
      if (compare(node, pattern)) {
        iterator(node);
      }
    });
  }
};

var compare = function(node, pattern) {
  if (node === pattern) {
      return true;
  }
  if ((node instanceof String && pattern instanceof String) ||
     (node instanceof Number && pattern instanceof Number)) {
      return node.toString() === pattern.toString();
  }
  if (!(node instanceof Object && pattern instanceof Object)) {
      return false;
  }
  for (var p in pattern) {
    if (pattern.hasOwnProperty(p)) {
      if(!node.hasOwnProperty(p) || typeof node[p] !== typeof pattern[p] || !compare(node[p], pattern[p])) {
        return false;
      }
    }
  }
  return true;
}

var expressionWalker = function(body, iterator) {
  for (var node in body) {
    iterator(node);
    // TODO find every sub expressions body and walk over it with expressionWalker(subexpressionsbody, pattern, iterator);
  };
}<commit_msg>fix compare not found<commit_after>module.exports = {
  compare: compare,
  expressions: function (cfg, pattern, iterator) {
    expressionWalker(cfg.body, function(node) {
      if (compare(node, pattern)) {
        iterator(node);
      }
    });
  }
};

function compare(node, pattern) {
  if (node === pattern) {
      return true;
  }
  if ((node instanceof String && pattern instanceof String) ||
     (node instanceof Number && pattern instanceof Number)) {
      return node.toString() === pattern.toString();
  }
  if (!(node instanceof Object && pattern instanceof Object)) {
      return false;
  }
  for (var p in pattern) {
    if (pattern.hasOwnProperty(p)) {
      if(!node.hasOwnProperty(p) || typeof node[p] !== typeof pattern[p] || !compare(node[p], pattern[p])) {
        return false;
      }
    }
  }
  return true;
}

function expressionWalker(body, iterator) {
  for (var node in body) {
    iterator(node);
    // TODO find every sub expressions body and walk over it with expressionWalker(subexpressionsbody, pattern, iterator);
  };
}
{'fraction_non_alphanumeric': 0.1354656632173095, 'fraction_numerical': 0.0, 'mean_word_length': 3.2035573122529644, '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': '5187223', 'n_tokens_mistral': 612, 'n_tokens_neox': 610, 'n_words': 181}