<commit_before>/* Basket.js 0.1
 * A script-loader that handles caching scripts in localStorage
 * where supported.
 * http://addyosmani.com/
 * Credits: <NAME>, <NAME>, Ironsjp.
 * Copyright (c) 2012 <NAME>; 
 * Licensed MIT, GPL 
 */
 ;(function (w, d) {

    function basketLoader() {

        var
        _storagePrefix = "basket-",
            _localStorage = function (a, b) {
                try {
                    return (a = localStorage).setItem(b, a), a.removeItem(b), !0
                } catch (c) {}
            }(),
            scripts = [],
            scriptsExecuted = 0,
            waitCount = 0,
            waitCallbacks = [],

            // Minimalist Cross-browser XHR
            // from https://gist.github.com/991713
            getXMLObj = function (s, a) {
                a = [a = "Msxml2.XMLHTTP", a + ".3.0", a + ".6.0"];
                do
                try {
                    s = a.pop();
                    return new(s ? ActiveXObject : XMLHttpRequest)(s)
                } catch (e) {;

                }
                while (s)
            },

            getUrl = function (url, callback) {
                var xhr = getXMLObj();
                xhr.open("GET", url, true);
                xhr.onreadystatechange = function (e) {
                    if (xhr.readyState === 4) {
                        callback(xhr.responseText);
                    }
                };
                xhr.send();
            },

            saveUrl= function(url, key){
                getUrl(url, function (text) {
                   localStorage.setItem(key, text);
                });
            },

            injectScript = function (text) {
                var script = d.createElement("script"),
                    fragment = d.createDocumentFragment(),
                    head = d.head || d.getElementsByTagName("head")[0];
                script.defer = true;
                script.appendChild(d.createTextNode(text));
                fragment.appendChild(script);
                head.appendChild(fragment);
            },

            queueExec = function (waitCount) {
                var script, i, j, callback;

                if (scriptsExecuted >= waitCount) {
                    for (i = 0; i < scripts.length; i++) {
                        script = scripts[i];

                        if (!script) {
                            // loading/executed
                            continue;
                        }
                        scripts[i] = null;
                        injectScript(script);
                        scriptsExecuted++;

                        for (j = i; j < scriptsExecuted; j++) {
                            if (callback = waitCallbacks[j]) {
                                waitCallbacks[j] = null;
                                callback();
                            }
                        }
                    }
                }
            };

        return {

            require: function (uri) {
                var key = _storagePrefix + uri,
                    scriptIndex = scripts.length,
                    _waitCount = waitCount;

                scripts[scriptIndex] = null;

                if (_localStorage && localStorage.getItem(key)) {
                    scripts[scriptIndex] = localStorage.getItem(key);
                    queueExec(_waitCount);
                } else {
                    getUrl(uri, function (text) {
                        (_localStorage) && localStorage.setItem(key, text);<commit_msg>Removes _localStorage junk. Fixes #8<commit_after>/* Basket.js 0.1
 * A script-loader that handles caching scripts in localStorage
 * where supported.
 * http://addyosmani.com/
 * Credits: <NAME>, <NAME>, Ironsjp.
 * Copyright (c) 2012 <NAME>;
 * Licensed MIT, GPL
 */
 ;(function (w, d) {

    function basketLoader() {

        var
        _storagePrefix = "basket-",
            scripts = [],
            scriptsExecuted = 0,
            waitCount = 0,
            waitCallbacks = [],

            // Minimalist Cross-browser XHR
            // from https://gist.github.com/991713
            getXMLObj = function (s, a) {
                a = [a = "Msxml2.XMLHTTP", a + ".3.0", a + ".6.0"];
                do
                try {
                    s = a.pop();
                    return new(s ? ActiveXObject : XMLHttpRequest)(s)
                } catch (e) {;

                }
                while (s)
            },

            getUrl = function (url, callback) {
                var xhr = getXMLObj();
                xhr.open("GET", url, true);
                xhr.onreadystatechange = function (e) {
                    if (xhr.readyState === 4) {
                        callback(xhr.responseText);
                    }
                };
                xhr.send();
            },

            saveUrl= function(url, key){
                getUrl(url, function (text) {
                   localStorage.setItem(key, text);
                });
            },

            injectScript = function (text) {
                var script = d.createElement("script"),
                    fragment = d.createDocumentFragment(),
                    head = d.head || d.getElementsByTagName("head")[0];
                script.defer = true;
                script.appendChild(d.createTextNode(text));
                fragment.appendChild(script);
                head.appendChild(fragment);
            },

            queueExec = function (waitCount) {
                var script, i, j, callback;

                if (scriptsExecuted >= waitCount) {
                    for (i = 0; i < scripts.length; i++) {
                        script = scripts[i];

                        if (!script) {
                            // loading/executed
                            continue;
                        }
                        scripts[i] = null;
                        injectScript(script);
                        scriptsExecuted++;

                        for (j = i; j < scriptsExecuted; j++) {
                            if (callback = waitCallbacks[j]) {
                                waitCallbacks[j] = null;
                                callback();
                            }
                        }
                    }
                }
            };

        return {

            require: function (uri) {
                var key = _storagePrefix + uri,
                    scriptIndex = scripts.length,
                    _waitCount = waitCount,
                    source = localStorage.getItem(key);

                scripts[scriptIndex] = null;

                if (source) {
                    scripts[scriptIndex] = source;
                    queueExec(_waitCount);
                } else {
                    getUrl(uri, function (text) {
                        localStorage.setItem(key, text);
{'fraction_non_alphanumeric': 0.10660267597440372, 'fraction_numerical': 0.006689936009307737, 'mean_word_length': 0.9910248986682108, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '7261732', 'n_tokens_mistral': 1774, 'n_tokens_neox': 1606, 'n_words': 366}