<commit_before>'use strict';

const { fullRecurseMap } = require('../utilities');

const { getOperator } = require('./operators');

// Try to simplify AST
const optimizeFilter = function ({ filter }) {
  return fullRecurseMap(filter, optimizeNode);
};

const optimizeNode = function (node) {
  const operator = getOperator({ node });
  // Is not a node
  if (operator === undefined) { return node; }

  const { optimize } = operator;
  if (optimize === undefined) { return node; }

  const nodeA = optimize(node);
  return nodeA;
};<commit_msg>Use mapNodes() with filter optimizer<commit_after>'use strict';

const { getOperator } = require('./operators');
const { mapNodes } = require('./crawl');

// Try to simplify AST
const optimizeFilter = function ({ filter }) {
  return mapNodes(filter, optimizeNode);
};

const optimizeNode = function (node) {
  const operator = getOperator({ node });

  const { optimize } = operator;
  if (optimize === undefined) { return node; }

  const nodeA = optimize(node);
  return nodeA;
};
{'fraction_non_alphanumeric': 0.14703018500486856, 'fraction_numerical': 0.0, 'mean_word_length': 4.191919191919192, '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': '7450119', 'n_tokens_mistral': 311, 'n_tokens_neox': 289, 'n_words': 93}