<commit_before>'use strict';

import lockr from 'lockr';

const LOCAL_STORAGE_TAB_DATA = 'vweb-';
const LOCAL_STORAGE_TAB_IDS = 'vweb1-tab-ids';

let storage = {};

storage.save = function (tabId, data) {
    if (!tabId) return;
    lockr.sadd(LOCAL_STORAGE_TAB_IDS, tabId);
    var key = LOCAL_STORAGE_TAB_DATA + tabId;
    lockr.set(key, data);
};

storage.load = function () {
    var ids = lockr.smembers(LOCAL_STORAGE_TAB_IDS);
    if (!ids) return [];

    var data = lockr.getAll().filter(val => {
        if (!val || !val.id) return false;
        return ids.indexOf(val.id) !== -1
    });

    data.sort(function (a, b) {
        var idxA = ids.indexOf(a.id);
        var idxB = ids.indexOf(b.id);
        if (idxA < idxB) return -1;
        else if (idxB < idxA) return 1;
        else return 0;
    });
    return data;
};

storage.remove = function (id) {
    lockr.srem(LOCAL_STORAGE_TAB_IDS, id);
    lockr.rm(LOCAL_STORAGE_TAB_DATA + id);
};

export default storage;<commit_msg>tabStorage: get localStorage value only for visualizer-on-tabs keys<commit_after>'use strict';

import lockr from 'lockr';

const LOCAL_STORAGE_TAB_DATA = 'vweb-';
const LOCAL_STORAGE_TAB_IDS = 'vweb1-tab-ids';

let storage = {};

storage.save = function (tabId, data) {
    if (!tabId) return;
    lockr.sadd(LOCAL_STORAGE_TAB_IDS, tabId);
    var key = LOCAL_STORAGE_TAB_DATA + tabId;
    lockr.set(key, data);
};

storage.load = function () {
    var ids = lockr.smembers(LOCAL_STORAGE_TAB_IDS);
    if (!ids) return [];

    var data = ids.map(id => {
        return Lockr.get(LOCAL_STORAGE_TAB_DATA + id);
    });

    data.sort(function (a, b) {
        var idxA = ids.indexOf(a.id);
        var idxB = ids.indexOf(b.id);
        if (idxA < idxB) return -1;
        else if (idxB < idxA) return 1;
        else return 0;
    });
    return data;
};

storage.remove = function (id) {
    lockr.srem(LOCAL_STORAGE_TAB_IDS, id);
    lockr.rm(LOCAL_STORAGE_TAB_DATA + id);
};

export default storage;
{'fraction_non_alphanumeric': 0.13984962406015036, 'fraction_numerical': 0.004511278195488722, 'mean_word_length': 3.0080321285140563, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '1321666', 'n_tokens_mistral': 773, 'n_tokens_neox': 748, 'n_words': 167}