<commit_before>var Immutable = require("immutable");

/**
 * @type {Cache}
 */
module.exports = Cache;

/**
 * @constructor
 */
function Cache () {

    var cache = this;

    cache._items = Immutable.Map({});

    cache.add = function (item) {
        cache._items = cache._items.set(item.get("key"), item);
        return item;
    };

    cache.byType = function (type, filter) {
        var byType = cache._items.filter(function (item) {
            return item.get("type") === type;
        });
        if (filter) {
            byType = byType.filter(filter);
        }
        return byType.toList();
    };

    cache.byKey = function (key) {<commit_msg>Use ordered map for cache<commit_after>var Immutable = require("immutable");

/**
 * @type {Cache}
 */
module.exports = Cache;

/**
 * @constructor
 */
function Cache () {

    var cache = this;

    cache._items = Immutable.OrderedMap({});

    cache.add = function (item) {
        cache._items = cache._items.set(item.get("key"), item);
        return item;
    };

    cache.byType = function (type, filter) {
        var byType = cache._items.filter(function (item) {
            return item.get("type") === type;
        });
        if (filter) {
            byType = byType.filter(filter);
        }
        return byType.toList();
    };

    cache.byKey = function (key) {
{'fraction_non_alphanumeric': 0.15934475055845124, 'fraction_numerical': 0.0, 'mean_word_length': 2.192399049881235, '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': '1816382', 'n_tokens_mistral': 417, 'n_tokens_neox': 408, 'n_words': 90}