<commit_before>define(['js/core/Component' , 'inherit'], function (Component, inherit) {

    /***
     * Local Storage implementation
     */
    var LocalStorage = Component.inherit('js.data.LocalStorage', {


        ctor: function () {

            this.$implementation = null;
            this.callBase();

            if (this.runsInBrowser()) {
                var window = this.$stage.$window,
                    document = this.$stage.$document;

                if ("localStorage" in window) {
                    try {
                        this.$implementation = window.localStorage;
                    } catch (e) {
                        typeof console !== "undefined" && console.log(e);
                    }
                }

                window.localStorage = window.localStorage || new LocalStorage.CookieImplementation(document);

            } else {
                this.$implementation = new LocalStorage.ObjectImplementation();
            }
        },

        getItem: function (key) {
            return this.$implementation.getItem(key);
        },

        setItem: function (key, value) {
            this.$implementation.setItem(key, value);
        },

        removeItem: function (key) {
            this.$implementation.removeItem(key);
        },

        clear: function() {
            this.$implementation.clear();
        }

    });

    // TODO: implement length as getter

    LocalStorage.CookieImplementation = inherit({

        getItem: function (sKey) {
            if (!sKey || !this.hasOwnProperty(sKey)) {
                return null;
            }
            return unescape(document.cookie.replace(new RegExp("(?:^|.*;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"), "$1"));
        },

        key: function (nKeyId) {
            return unescape(document.cookie.replace(/\s*=(?:.(?!;))*$/, "").split(/\s*=(?:[^;](?!;))*[^;]?;\s*/)[nKeyId]);
        },

        setItem: function (sKey, sValue) {
            if (!sKey) {
                return;
            }
            document.cookie = escape(sKey) + "=" + escape(sValue) + "; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/";
            this.length = document.cookie.match(/=/g).length;
        },

        length: 0,

        size: function() {
            this.$implementation.length = document.cookie.match(/=/g).length;
        },

        removeItem: function (sKey) {
            if (!sKey || !this.hasOwnProperty(sKey)) {
                return;
            }
            document.cookie = escape(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
            this.length--;
        }
//        ,
//        hasOwnProperty: function (sKey) {
//            return (new RegExp("(?:^|;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie);
//        }
    });

    // TODO: implement length as getter

    LocalStorage.ObjectImplementation = inherit({

        ctor: function() {
            this.clear();
        },

        getItem: function (key) {
            return this.$storage[key];
        },

        setItem: function (key, value) {
            this.$storage[key] = value;
        },

        removeItem: function (key) {
            delete this.$storage[key];
        },

        clear: function() {
            this.$storage = {};
        }
    });

    return LocalStorage;

});<commit_msg>fixed feature detection for localstorage for 3rd party applications<commit_after>define(['js/core/Component' , 'inherit'], function (Component, inherit) {

    /***
     * Local Storage implementation
     */
    var LocalStorage = Component.inherit('js.data.LocalStorage', {


        ctor: function () {

            this.$implementation = null;
            this.callBase();

            if (this.runsInBrowser()) {
                var window = this.$stage.$window,
                    document = this.$stage.$document;

                if ("localStorage" in window) {
                    try {
                        this.$implementation = window.localStorage;
                    } catch (e) {
                        typeof console !== "undefined" && console.log(e);
                    }
                }

                this.$implementation = this.$implementation || new LocalStorage.CookieImplementation(document);

            } else {
                this.$implementation = new LocalStorage.ObjectImplementation();
            }
        },

        getItem: function (key) {
            return this.$implementation.getItem(key);
        },

        setItem: function (key, value) {
            this.$implementation.setItem(key, value);
        },

        removeItem: function (key) {
            this.$implementation.removeItem(key);
        },

        clear: function() {
            this.$implementation.clear();
        }

    });

    // TODO: implement length as getter

    LocalStorage.CookieImplementation = inherit({

        getItem: function (sKey) {
            if (!sKey || !this.hasOwnProperty(sKey)) {
                return null;
            }
            return unescape(document.cookie.replace(new RegExp("(?:^|.*;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"), "$1"));
        },

        key: function (nKeyId) {
            return unescape(document.cookie.replace(/\s*=(?:.(?!;))*$/, "").split(/\s*=(?:[^;](?!;))*[^;]?;\s*/)[nKeyId]);
        },

        setItem: function (sKey, sValue) {
            if (!sKey) {
                return;
            }
            document.cookie = escape(sKey) + "=" + escape(sValue) + "; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/";
            this.length = document.cookie.match(/=/g).length;
        },

        length: 0,

        size: function() {
            this.$implementation.length = document.cookie.match(/=/g).length;
        },

        removeItem: function (sKey) {
            if (!sKey || !this.hasOwnProperty(sKey)) {
                return;
            }
            document.cookie = escape(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
            this.length--;
        }
//        ,
//        hasOwnProperty: function (sKey) {
//            return (new RegExp("(?:^|;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie);
//        }
    });

    // TODO: implement length as getter

    LocalStorage.ObjectImplementation = inherit({

        ctor: function() {
            this.clear();
        },

        getItem: function (key) {
            return this.$storage[key];
        },

        setItem: function (key, value) {
            this.$storage[key] = value;
        },

        removeItem: function (key) {
            delete this.$storage[key];
        },

        clear: function() {
            this.$storage = {};
        }
    });

    return LocalStorage;

});
{'fraction_non_alphanumeric': 0.17180232558139535, 'fraction_numerical': 0.007703488372093024, 'mean_word_length': 1.5723364485981308, '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': '1424283', 'n_tokens_mistral': 2032, 'n_tokens_neox': 1844, 'n_words': 348}