<commit_before>/**
 * Preload a collection of images (license : GPL v2)
 * @author <NAME>
 *
 * @param {(object|string[])} srcCollection - A collection of images
 * @param {function(object)=} callbackOne - A function callback that is called after each loading
 * @param {function((object|object[]))=} callbackAll - A function callback that is called after all the loading
 * @param {boolean} [sequential=false] - A boolean defining wheter to force the sequential loading. Default : false.
 *
 */
function preloadr(srcCollection, callbackOne, callbackAll, sequential) {

    sequential = typeof sequential !== 'undefined' ? sequential : false;

    var imgCollection = srcCollection instanceof Array ? [] : {};
    var srcIndexArray = [];
    for (var key in srcCollection) {
        srcIndexArray.push(key);
    }

    function onEvent(index) {
        return function () {
                    load(imgCollection[srcIndexArray[index]], (function () {
                        if (sequential && index < srcIndexArray.length - 1) {
                            return function () {
                                var newIndex = srcIndexArray[index + 1];
                                imgCollection[newIndex].src = srcCollection[newIndex];
                            };
                        } else {
                            return null;
                        }
                    })());
                };
    }

    function load(image, callback) {
        if (isFunctionCallbackOne) {
            callbackOne(image);
        }
        if (callback && 'function' === typeof callback) {
            callback();
        }
        if (++nbLoaded >= nbToLoad && 'function' === typeof callbackAll) {
            callbackAll(imgCollection);
        }
    }

    if (srcIndexArray.length) {
        var nbLoaded = 0,
            nbToLoad = 0;
        var isFunctionCallbackOne = 'function' === typeof callbackOne;
        for (var i = 0; i < srcIndexArray.length; i++) {

            nbToLoad++;
            imgCollection[srcIndexArray[i]] = new Image();
            imgCollection[srcIndexArray[i]].onload = imgCollection[srcIndexArray[i]].onerror = imgCollection[srcIndexArray[i]].onabort = onEvent(i);

            if (!sequential) {
                imgCollection[srcIndexArray[i]].src = srcCollection[srcIndexArray[i]].src;
                imgCollection[srcIndexArray[i]].props = srcCollection[srcIndexArray[i]].props;
            }
        }
        if (sequential) {
            imgCollection[srcIndexArray[0]].src = srcCollection[srcIndexArray[0]];
        }
    }
}<commit_msg>forgot to add props on sequential load<commit_after>/**
 * Preload a collection of images (license : GPL v2)
 * @author <NAME>
 *
 * @param {(object|string[])} srcCollection - A collection of images
 * @param {function(object)=} callbackOne - A function callback that is called after each loading
 * @param {function((object|object[]))=} callbackAll - A function callback that is called after all the loading
 * @param {boolean} [sequential=false] - A boolean defining wheter to force the sequential loading. Default : false.
 *
 */
function preloadr(srcCollection, callbackOne, callbackAll, sequential) {

    sequential = typeof sequential !== 'undefined' ? sequential : false;

    var imgCollection = srcCollection instanceof Array ? [] : {};
    var srcIndexArray = [];
    for (var key in srcCollection) {
        srcIndexArray.push(key);
    }

    function onEvent(index) {
        return function () {
                    load(imgCollection[srcIndexArray[index]], (function () {
                        if (sequential && index < srcIndexArray.length - 1) {
                            return function () {
                                var newIndex = srcIndexArray[index + 1];
                                imgCollection[newIndex].src = srcCollection[newIndex];
                            };
                        } else {
                            return null;
                        }
                    })());
                };
    }

    function load(image, callback) {
        if (isFunctionCallbackOne) {
            callbackOne(image);
        }
        if (callback && 'function' === typeof callback) {
            callback();
        }
        if (++nbLoaded >= nbToLoad && 'function' === typeof callbackAll) {
            callbackAll(imgCollection);
        }
    }

    if (srcIndexArray.length) {
        var nbLoaded = 0,
            nbToLoad = 0;
        var isFunctionCallbackOne = 'function' === typeof callbackOne;
        for (var i = 0; i < srcIndexArray.length; i++) {

            nbToLoad++;
            imgCollection[srcIndexArray[i]] = new Image();
            imgCollection[srcIndexArray[i]].onload = imgCollection[srcIndexArray[i]].onerror = imgCollection[srcIndexArray[i]].onabort = onEvent(i);

            if (!sequential) {
                imgCollection[srcIndexArray[i]].src = srcCollection[srcIndexArray[i]].src;
                imgCollection[srcIndexArray[i]].props = srcCollection[srcIndexArray[i]].props;
            }
        }
        if (sequential) {
            imgCollection[srcIndexArray[0]].src = srcCollection[srcIndexArray[0]];
			imgCollection[srcIndexArray[i]].props = srcCollection[srcIndexArray[i]].props;
        }
    }
}
{'fraction_non_alphanumeric': 0.11475099412989964, 'fraction_numerical': 0.0030297292179511455, 'mean_word_length': 2.0269340974212033, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3159543', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1336, 'n_words': 326}