<commit_before>var fs = require('fs'),
  index = require('./');

index.save = function(db, destination) {
  destination = destination || 'db.json';
  fs.writeFileSync(destination, JSON.stringify(db));
};

index.load = function(source) {
  source = source || 'db.json';
  return JSON.parse(fs.readFileSync(source, 'utf-8'));
};

module.exports = index;<commit_msg>Add throttled save<commit_after>var fs = require('fs'),
  index = require('./');

index.save = function(db, destination) {
  destination = destination || 'db.json';
  fs.writeFileSync(destination, JSON.stringify(db));
};

index.load = function(source) {
  source = source || 'db.json';
  return JSON.parse(fs.readFileSync(source, 'utf-8'));
};

index.throttledSave = function(db, destination, wait) {
  wait = wait || 100;
  _.throttle(index.save(db, destination), wait);
}

module.exports = index;
{'fraction_non_alphanumeric': 0.18234610917537747, 'fraction_numerical': 0.005807200929152149, 'mean_word_length': 4.904109589041096, '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': '2297570', 'n_tokens_mistral': 285, 'n_tokens_neox': 279, 'n_words': 57}