<commit_before>// Requires
var Q = require('q');
var _ = require('underscore');

var qClass = require('qpatch').qClass;

// Etcd client
var Etcd = qClass(require('node-etcd'), ['watcher']);


// Since etcd create the dir keys automatically
// transform the tree of keys
// to contain only a flat array of leaves
function cleanDump(obj) {
    // Is a leaf
    if(!_.has(obj, 'kvs')) {
        // We don't want the modifiedIndex attr in our dumps/restores
        return _.pick(obj, 'key', 'value');
    }
    return _.flatten(_.map(obj.kvs, cleanInput));
}


function Dumper(etcd) {
    // ETCD client
    this.store = new Etcd();

    _.bindAll(this);
}

// Get a JS object of the DB
Dumper.prototype.dump = function() {
    return this.store.get('', {
        recusrive: true
    })
    .then(cleanDump);
};

// Restore a list of keys
Dumper.prototype.restore = function(entries) {
    var self = this;<commit_msg>Fix typo cleanInput => cleanDump<commit_after>// Requires
var Q = require('q');
var _ = require('underscore');

var qClass = require('qpatch').qClass;

// Etcd client
var Etcd = qClass(require('node-etcd'), ['watcher']);


// Since etcd create the dir keys automatically
// transform the tree of keys
// to contain only a flat array of leaves
function cleanDump(obj) {
    // Is a leaf
    if(!_.has(obj, 'kvs')) {
        // We don't want the modifiedIndex attr in our dumps/restores
        return _.pick(obj, 'key', 'value');
    }
    return _.flatten(_.map(obj.kvs, cleanDump));
}


function Dumper(etcd) {
    // ETCD client
    this.store = new Etcd();

    _.bindAll(this);
}

// Get a JS object of the DB
Dumper.prototype.dump = function() {
    return this.store.get('', {
        recusrive: true
    })
    .then(cleanDump);
};

// Restore a list of keys
Dumper.prototype.restore = function(entries) {
    var self = this;
{'fraction_non_alphanumeric': 0.1471861471861472, 'fraction_numerical': 0.0, 'mean_word_length': 2.9256900212314223, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '7067452', 'n_tokens_mistral': 614, 'n_tokens_neox': 600, 'n_words': 184}