<commit_before>var Fuse = require('fuse.js');

var fuzzyFilter = function(value, options) {
  var defaultOptions = {
    threshold: 0.6,
    location: 0,
    distance: 100,
    maxPatternLength: 32,
    keys: []
  };

  var fuse = null;
  var result = null;

  return function(val, key, array) {
    if (!fuse || !result) {
      fuse = new Fuse(array, options || defaultOptions)
      result = fuse.search(value);
    }
    return result.indexOf(key) !== -1;
  };
}

module.exports = fuzzyFilter;<commit_msg>better options management<commit_after>var Fuse = require('fuse.js');

var fuzzyFilter = function(value, options = {}) {
  var defaultOptions = {
    threshold: 0.4,
    location: 0,
    distance: 100,
    maxPatternLength: 32,
    keys: []
  };

  var fuse = null;
  var result = null;

  return function(val, key, array) {
    if (!fuse || !result) {
      fuse = new Fuse(array, Object.assign(defaultOptions, options))
      result = fuse.search(value);
    }
    return result.indexOf(key) !== -1;
  };
}

module.exports = fuzzyFilter;
{'fraction_non_alphanumeric': 0.14408396946564886, 'fraction_numerical': 0.01717557251908397, 'mean_word_length': 3.0191570881226055, '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': '5224848', 'n_tokens_mistral': 375, 'n_tokens_neox': 343, 'n_words': 87}