<commit_before>const Cookies          = require('js-cookie');
const getPropertyValue = require('./utility').getPropertyValue;
const isEmptyObject    = require('./utility').isEmptyObject;

const isStorageSupported = (storage) => {
    if (typeof storage === 'undefined') {
        return false;
    }

    const test_key = 'test';
    try {
        storage.setItem(test_key, '1');
        storage.removeItem(test_key);
        return true;
    } catch (e) {
        return false;
    }
};

const Store = function(storage) {
    this.storage = storage;
};

Store.prototype = {
    get: function(key) {
        return this.storage.getItem(key) || undefined;
    },
    set: function(key, value) {
        if (typeof value !== 'undefined') {
            this.storage.setItem(key, value);
        }
    },
    remove: function(key) { this.storage.removeItem(key); },
    clear : function()    { this.storage.clear(); },
};

const InScriptStore = function(object) {
    this.store = typeof object !== 'undefined' ? object : {};
};

InScriptStore.prototype = {
    get: function(key) {
        return getPropertyValue(this.store, key);
    },
    set: function(key, value, obj = this.store) {
        if (!Array.isArray(key)) key = [key];
        if (key.length > 1) {<commit_msg>Simplify using objects in storages<commit_after>const Cookies          = require('js-cookie');
const getPropertyValue = require('./utility').getPropertyValue;
const isEmptyObject    = require('./utility').isEmptyObject;

const getObject = function(key) {
    return JSON.parse(this.getItem(key) || '{}');
};

const setObject = function(key, value) {
    if (value && value instanceof Object) {
        this.setItem(key, JSON.stringify(value));
    }
};

if (typeof Storage !== 'undefined') {
    Storage.prototype.getObject = getObject;
    Storage.prototype.setObject = setObject;
}

const isStorageSupported = (storage) => {
    if (typeof storage === 'undefined') {
        return false;
    }

    const test_key = 'test';
    try {
        storage.setItem(test_key, '1');
        storage.removeItem(test_key);
        return true;
    } catch (e) {
        return false;
    }
};

const Store = function(storage) {
    this.storage = storage;
    this.storage.getObject = getObject;
    this.storage.setObject = setObject;
};

Store.prototype = {
    get: function(key) {
        return this.storage.getItem(key) || undefined;
    },
    set: function(key, value) {
        if (typeof value !== 'undefined') {
            this.storage.setItem(key, value);
        }
    },
    getObject: function (key) {
        return this.storage.getObject(key);
    },
    setObject: function (key, value) {
        this.storage.setObject(key, value);
    },
    remove: function(key) { this.storage.removeItem(key); },
    clear : function()    { this.storage.clear(); },
};

const InScriptStore = function(object) {
    this.store = typeof object !== 'undefined' ? object : {};
};

InScriptStore.prototype = {
    get: function(key) {
        return getPropertyValue(this.store, key);
    },
    set: function(key, value, obj = this.store) {
        if (!Array.isArray(key)) key = [key];
        if (key.length > 1) {
{'fraction_non_alphanumeric': 0.1504396984924623, 'fraction_numerical': 0.001256281407035176, 'mean_word_length': 2.751472320376914, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3296324', 'n_tokens_mistral': 956, 'n_tokens_neox': 954, 'n_words': 209}