<commit_before>/* global browser */
define('ready', function () {

    /*global document, query */
    var callbacks = [],
        win = window,
        doc = document,
        ADD_EVENT_LISTENER = 'addEventListener',
        REMOVE_EVENT_LISTENER = 'removeEventListener',
        ATTACH_EVENT = 'attachEvent',
        DETACH_EVENT = 'detachEvent',
        DOM_CONTENT_LOADED = 'DOMContentLoaded',
        ON_READY_STATE_CHANGE = 'onreadystatechange',
        COMPLETE = 'complete',
        READY_STATE = 'readyState';

    var ready = function (callback) {
        callbacks.push(callback);
        if (doc[READY_STATE] === COMPLETE) {
            // Handle it asynchronously to allow scripts the opportunity to delay ready
            setTimeout(invokeCallbacks);
        }
    };

    var DOMContentLoaded;

    function invokeCallbacks() {
        var i = 0, len = callbacks.length;
        while (i < len) {
            callbacks[i]();
            i += 1;
        }
        callbacks.length = 0;
    }

    // Cleanup functions for the document ready method
    // attached in the bindReady handler
    if (doc[ADD_EVENT_LISTENER]) {
        DOMContentLoaded = function () {
            doc[REMOVE_EVENT_LISTENER](DOM_CONTENT_LOADED, DOMContentLoaded, false);
            invokeCallbacks();
        };

    } else if (doc.attachEvent) {
        DOMContentLoaded = function () {
            // Make sure body exists, at least, in case IE gets a little overzealous
            if (doc[READY_STATE] === COMPLETE) {
                doc[DETACH_EVENT](ON_READY_STATE_CHANGE, DOMContentLoaded);
                invokeCallbacks();
            }
        };
    }

    // Catch cases where $(document).ready() is called after the
    // browser event has already occurred.
    if (doc[READY_STATE] === COMPLETE) {<commit_msg>ready callbacks could be called multiple times. fixed.<commit_after>/* global browser */
define('ready', function () {

    /*global document, query */
    var callbacks = [],
        win = window,
        doc = document,
        ADD_EVENT_LISTENER = 'addEventListener',
        REMOVE_EVENT_LISTENER = 'removeEventListener',
        ATTACH_EVENT = 'attachEvent',
        DETACH_EVENT = 'detachEvent',
        DOM_CONTENT_LOADED = 'DOMContentLoaded',
        ON_READY_STATE_CHANGE = 'onreadystatechange',
        COMPLETE = 'complete',
        READY_STATE = 'readyState';

    var ready = function (callback) {
        callbacks.push(callback);
        if (doc[READY_STATE] === COMPLETE) {
            // Handle it asynchronously to allow scripts the opportunity to delay ready
            setTimeout(invokeCallbacks);
        }
    };

    var DOMContentLoaded;

    function invokeCallbacks() {
        var ary = callbacks.slice();
        callbacks.length = 0;
        for(var i = 0; i < ary.length; i += 1) {
            ary[i]();
        }
    }

    // Cleanup functions for the document ready method
    // attached in the bindReady handler
    if (doc[ADD_EVENT_LISTENER]) {
        DOMContentLoaded = function () {
            doc[REMOVE_EVENT_LISTENER](DOM_CONTENT_LOADED, DOMContentLoaded, false);
            invokeCallbacks();
        };

    } else if (doc.attachEvent) {
        DOMContentLoaded = function () {
            // Make sure body exists, at least, in case IE gets a little overzealous
            if (doc[READY_STATE] === COMPLETE) {
                doc[DETACH_EVENT](ON_READY_STATE_CHANGE, DOMContentLoaded);
                invokeCallbacks();
            }
        };
    }

    // Catch cases where $(document).ready() is called after the
    // browser event has already occurred.
    if (doc[READY_STATE] === COMPLETE) {
{'fraction_non_alphanumeric': 0.10321350762527233, 'fraction_numerical': 0.0016339869281045752, 'mean_word_length': 2.185602775368604, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7290087', 'n_tokens_mistral': 1041, 'n_tokens_neox': 1007, 'n_words': 261}