<commit_before>var _ = require('lodash');
(function(){
    /**
     * Indexed Collection Constructor
     * @constructor
     */
    function IndexedCollection(){
        this.vector = [];
        this.index = {};
        Object.defineProperty(this, 'length', {
            get: function () {
                return this.vector.length
            }
        });
    }

    /**
     * Add new item
     * @param {Object} data
     */
    IndexedCollection.prototype.add = function (data) {
        if (!data.id) {
            throw new Error('No ID informed to IndexedCollection.prototype.add');
        }
        if (this.index[data.id]) {
            return this.edit(data.id, data);
        }
        var itemIndex = this.vector.push(data);
        this.index[data.id] = itemIndex - 1;
        return itemIndex;
    }

    /**
     * Find an item by subitems matching
     * @param  {Mixed} query Can be a string or object
     */
    IndexedCollection.prototype.find = function (subject) {
        var query;
        if (typeof subject == string || typeof subject == number) {

        }
    }

    /**
     * Find an item by ID
     * @param  {String} id
     * @return {Object}
     */
    IndexedCollection.prototype.findById = function (id) {
        var idx = this.index[id];
        return this.vector[idx];
    }

    /**
     * Edit a item's data recusively
     * @param  {String} id
     * @param  {Object} data
     * @return {Boolean} true if edition is done
     */
    IndexedCollection.prototype.edit = function (id, data) {
        var idx = this.index[id];
        if (!this.vector[idx]) {
            throw new Error('Item not found');
        }
        this.vector[idx] = _.merge(data, this.vector[idx]);
        return true;
    }

    /**
     * Remove an item
     * @param  {String} id
     */
    IndexedCollection.prototype.remove = function (id) {
        var idx = this.index[id];
        delete this.vector[idx];
        delete this.index[id];
        this._rebuildIndex();
    }

    IndexedCollection.prototype._rebuildIndex = function () {
        for (var i = 0; i < this.vector.length; i++) {
            this.vector[i]
        };
    }

    this.IndexedCollection = IndexedCollection;<commit_msg>Use only a internal data object<commit_after>var _ = require('lodash');
(function(){
    /**
     * Indexed Collection Constructor
     * @constructor
     */
    function IndexedCollection () {
        this.data = {};
    }

    /**
     * Add new item
     * @param {Object} data
     */
    IndexedCollection.prototype.add = function (data) {
        if (!data.id) {
            throw new Error('No ID informed to IndexedCollection.prototype.add');
        }
        if (this.data[data.id]) {
            return this.edit(data.id, data);
        }
        this.data[data.id] = data;
    }

    /**
     * Find an item by subitems matching
     * @param  {Mixed} query Can be a string or object
     */
    IndexedCollection.prototype.find = function (subject) {
        var query;
        if (typeof subject == string || typeof subject == number) {

        }
    }

    /**
     * Find an item by ID
     * @param  {String} id
     * @return {Object}
     */
    IndexedCollection.prototype.findById = function (id) {
        return this.data[idx];
    }

    /**
     * Edit a item's data recusively
     * @param  {String} id
     * @param  {Object} data
     * @return {Boolean} true if edition is done
     */
    IndexedCollection.prototype.edit = function (id, data) {
        if (!this.data[id]) {
            throw new Error('Item not found');
        }
        this.data[id] = _.merge(data, this.data[id]);
        return true;
    }

    /**
     * Remove an item
     * @param  {String} id
     */
    IndexedCollection.prototype.remove = function (id) {
        delete this.data[id];
    }

    this.IndexedCollection = IndexedCollection;
{'fraction_non_alphanumeric': 0.1276376737004632, 'fraction_numerical': 0.000514668039114771, 'mean_word_length': 1.8146270818247647, 'pattern_counts': {'":': 0, '<': 4, '<?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': '1308923', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1130, 'n_words': 287}