<commit_before>import * as _ from 'lodash'
import UUID from 'node-uuid';

let KEY = 'GIFS';

if (process.env.NODE_ENV === 'development') {
    KEY = 'GIFS_TEST';
}

export const loadData = () => {
    let data = JSON.parse(localStorage.getItem(KEY));

    if (_.isEmpty(data)) {
        return [];
    } else {
        return data;
    }
};

export const update = (update) => {
    localStorage.setItem(KEY, JSON.stringify(update));
};

export const mock = (max = 10) => {
    localStorage.removeItem(KEY);

    let data = {};

    for (let i = 0; i < max; i++) {
        let id = UUID.v4();

        data[id] = {
            id: id,
            name: 'Test ' + i,
            url: 'http://media2.giphy.com/media/geozuBY5Y6cXm/giphy.gif',
            still_url: 'https://media2.giphy.com/media/geozuBY5Y6cXm/giphy_s.gif',
            priority: _.random(0, 100)
        };
    }

    localStorage.setItem(KEY, JSON.stringify(data));
};<commit_msg>Return {} if empty<commit_after>import * as _ from 'lodash'
import UUID from 'node-uuid';

let KEY = 'GIFS';

if (process.env.NODE_ENV === 'development') {
    KEY = 'GIFS_TEST';
}

export const loadData = () => {
    let data = JSON.parse(localStorage.getItem(KEY));

    if (_.isEmpty(data)) {
        return {};
    } else {
        return data;
    }
};

export const update = (update) => {
    localStorage.setItem(KEY, JSON.stringify(update));
};

export const mock = (max = 10) => {
    localStorage.removeItem(KEY);

    let data = {};

    for (let i = 0; i < max; i++) {
        let id = UUID.v4();

        data[id] = {
            id: id,
            name: 'Test ' + i,
            url: 'http://media2.giphy.com/media/geozuBY5Y6cXm/giphy.gif',
            still_url: 'https://media2.giphy.com/media/geozuBY5Y6cXm/giphy_s.gif',
            priority: _.random(0, 100)
        };
    }

    localStorage.setItem(KEY, JSON.stringify(data));
};
{'fraction_non_alphanumeric': 0.1676331049024776, 'fraction_numerical': 0.014760147601476014, 'mean_word_length': 2.2724137931034485, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '7086220', 'n_tokens_mistral': 708, 'n_tokens_neox': 683, 'n_words': 136}