<commit_before>(function (window) {
    'use strict';

    var storageTypes = {
        localStorage: window.localStorage,
        sessionStorage: window.sessionStorage
    };

    /**
     * main constructor
     *
     * @param {Object} settings
     * @return {this}
     * @public
     */

    var LS = function LS (settings) {
        var currentDate = new Date().getTime();

        // merge default settings with custom settings
        this.settings = Object.assign({}, LS.defaultSettings, settings);

        // configure storage type
        this.settings.storageType = storageTypes[this.settings.storageType] || storageTypes.localStorage;

        if (this.settings.endpoint) {

            // if local storage exists configure instance settings and properties accordingly
            if (this.settings.storageType[this.settings.endpoint] !== undefined) {
                this.storageItem = JSON.parse(this.settings.storageType[this.settings.endpoint]);

                // remove expired storage
                if (this.settings.expires !== undefined) {
                    if (currentDate > (this.storageItem.dateCreated + this.settings.expires)) {
                        this.remove();
                    }
                }

                return this;

            // if local storage doesn't exist get storageItem object ready to be set
            } else {
                this.storageItem = {};
                this.storageItem.dateCreated = new Date().getTime();

                return this;
            }
        } else {
            throw new Error('This constructor function requires a settings object');
        }
    };

    /**
     * LS default settings
     */

    LS.defaultSettings = {
        storageType: storageTypes.localStorage,
        endpoint: undefined,
        expires: undefined
    };

    /**
     * get local storage data and provide object to client with optional callback
     *
     * @param {Object} data
     * @return {this}
     * @public
     */

    LS.prototype.set = function (data) {
        if (data) {
            this.storageItem.endpoint = this.settings.endpoint;
            this.storageItem.data = data;
            this.storageItem.dateCreated = this.storageItem.dateCreated || new Date().getTime();
            this.settings.storageType[this.settings.endpoint] = JSON.stringify(this.storageItem);

            return this;
        } else {
            throw new Error('This function requires an object or array argument');
        }
    };

    /**
     * get local storage data and provide object to client with optional callback
     *
     * @param {Function} fn
     * @return {this}
     * @public
     */

    LS.prototype.get = LS.prototype.find = function (fn) {
        if (this.settings.storageType[this.settings.endpoint] !== undefined) {
            this.storageItem = JSON.parse(this.settings.storageType[this.settings.endpoint]);
<commit_msg>update comments<commit_after>(function (window) {
    'use strict';

    var storageTypes = {
        localStorage: window.localStorage,
        sessionStorage: window.sessionStorage
    };

    /**
     * main constructor
     *
     * @param {Object} settings
     * @return {this}
     * @public
     */

    var LS = function LS (settings) {
        var currentDate = new Date().getTime();

        // merge default settings with custom settings
        this.settings = Object.assign({}, LS.defaultSettings, settings);

        // configure storage type
        this.settings.storageType = storageTypes[this.settings.storageType] || storageTypes.localStorage;

        if (this.settings.endpoint) {

            // if local storage exists configure instance settings and properties accordingly
            if (this.settings.storageType[this.settings.endpoint] !== undefined) {
                this.storageItem = JSON.parse(this.settings.storageType[this.settings.endpoint]);

                // remove expired storage
                if (this.settings.expires !== undefined) {
                    if (currentDate > (this.storageItem.dateCreated + this.settings.expires)) {
                        this.remove();
                    }
                }

                return this;

            // if local storage doesn't exist get storageItem object ready to be set
            } else {
                this.storageItem = {};
                this.storageItem.dateCreated = new Date().getTime();

                return this;
            }
        } else {
            throw new Error('This constructor function requires a settings object');
        }
    };

    /**
     * LS default settings
     */

    LS.defaultSettings = {
        storageType: storageTypes.localStorage,
        endpoint: undefined,
        expires: undefined
    };

    /**
     * set local storage and instance data
     *
     * @param {Object} data
     * @return {this}
     * @public
     */

    LS.prototype.set = function (data) {
        if (data) {
            this.storageItem.endpoint = this.settings.endpoint;
            this.storageItem.data = data;
            this.storageItem.dateCreated = this.storageItem.dateCreated || new Date().getTime();
            this.settings.storageType[this.settings.endpoint] = JSON.stringify(this.storageItem);

            return this;
        } else {
            throw new Error('This function requires an object or array argument');
        }
    };

    /**
     * get local storage data and provide object to client with optional callback
     *
     * @param {Function} fn
     * @return {this}
     * @public
     */

    LS.prototype.get = LS.prototype.find = function (fn) {
        if (this.settings.storageType[this.settings.endpoint] !== undefined) {
            this.storageItem = JSON.parse(this.settings.storageType[this.settings.endpoint]);

{'fraction_non_alphanumeric': 0.10386930352536543, 'fraction_numerical': 0.0, 'mean_word_length': 1.8820614469772052, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1710978', 'n_tokens_mistral': 1482, 'n_tokens_neox': 1403, 'n_words': 365}