<commit_before>JARS.internal('LoaderQueue', function(InternalsManager) {
    'use strict';

    var arrayEach = InternalsManager.get('utils').arrayEach,
        Resolver = InternalsManager.get('Resolver'),
        InterceptionManager = InternalsManager.get('InterceptionManager'),
        ModuleLogger = InternalsManager.get('ModuleLogger'),
        SEPERATOR = '", "',
        MODULE = 'module ',
        BUNDLE = 'bundle ',
        SUBSCRIBED_TO = 'subscribed to "${subs}"',
        NOTIFIED_BY = 'was notified by "${pub}"',
        MSG_MODULE_NOTIFIED = ModuleLogger.addDebug(MODULE + NOTIFIED_BY),
        MSG_MODULE_SUBSCRIBED = ModuleLogger.addDebug(MODULE + SUBSCRIBED_TO),
        MSG_BUNDLE_NOTIFIED = ModuleLogger.addDebug(BUNDLE + NOTIFIED_BY, true),
        MSG_BUNDLE_SUBSCRIBED = ModuleLogger.addDebug(BUNDLE + SUBSCRIBED_TO, true);

    function LoaderQueue(module, isBundleQueue, callback, progressback, errback) {
        this._module = module;
        this._isBundleQueue = isBundleQueue;
        this._counter = 0;
        this._total = 0;
        this._callback = callback;
        this._progressback = progressback;
        this._errback = errback || function onModuleAborted(abortedModuleName) {
            module.isRoot() || module.abort(isBundleQueue, abortedModuleName);
        };
    }

    LoaderQueue.prototype = {
        constructor: LoaderQueue,

        loadModules: function(moduleNames) {
            var loaderQueue = this,
                module = loaderQueue._module,
                logger = module.logger,
                loader = module.loader,
                isBundleQueue = loaderQueue._isBundleQueue,
                listenerName = module.getName(isBundleQueue);

            logger.log(isBundleQueue ? MSG_BUNDLE_SUBSCRIBED : MSG_MODULE_SUBSCRIBED, {
                subs: moduleNames.join(SEPERATOR)
            });

            loaderQueue._total += moduleNames.length;

            arrayEach(moduleNames, function loadModule(moduleName) {
                var isBundle = Resolver.isBundle(moduleName);

                loader.getModule(moduleName).request(isBundle).onLoad(InterceptionManager.intercept(loader, listenerName, moduleName, function onModuleLoaded(publishingModuleName, data) {
                    var percentageLoaded = Number((loaderQueue._counter++/loaderQueue._total).toFixed(2));

                    logger.log(isBundleQueue ? MSG_BUNDLE_NOTIFIED : MSG_MODULE_NOTIFIED, {
                        pub: publishingModuleName
                    });

                    loaderQueue._progressback(publishingModuleName, data, percentageLoaded);
                    loaderQueue._callIfReady();
                }, loaderQueue._errback), loaderQueue._errback, isBundle);
            });

            !loaderQueue._total && loaderQueue._callIfReady();
        },

        _callIfReady: function() {
            var loaderQueue = this;

            if(loaderQueue._counter === loaderQueue._total) {
                loaderQueue._callback();
            }
        }
    };

    return LoaderQueue;
});<commit_msg>Rename and provide default for onModuleLoaded()<commit_after>JARS.internal('LoaderQueue', function(InternalsManager) {
    'use strict';

    var arrayEach = InternalsManager.get('utils').arrayEach,
        Resolver = InternalsManager.get('Resolver'),
        InterceptionManager = InternalsManager.get('InterceptionManager'),
        ModuleLogger = InternalsManager.get('ModuleLogger'),
        SEPERATOR = '", "',
        MODULE = 'module ',
        BUNDLE = 'bundle ',
        SUBSCRIBED_TO = 'subscribed to "${subs}"',
        NOTIFIED_BY = 'was notified by "${pub}"',
        MSG_MODULE_NOTIFIED = ModuleLogger.addDebug(MODULE + NOTIFIED_BY),
        MSG_MODULE_SUBSCRIBED = ModuleLogger.addDebug(MODULE + SUBSCRIBED_TO),
        MSG_BUNDLE_NOTIFIED = ModuleLogger.addDebug(BUNDLE + NOTIFIED_BY, true),
        MSG_BUNDLE_SUBSCRIBED = ModuleLogger.addDebug(BUNDLE + SUBSCRIBED_TO, true);

    function LoaderQueue(module, isBundleQueue, onModulesLoaded, onModuleLoaded, onModuleAborted) {
        this._module = module;
        this._isBundleQueue = isBundleQueue;
        this._counter = 0;
        this._total = 0;
        this._onModulesLoaded = onModulesLoaded;
        this._onModuleLoaded = onModuleLoaded || function onModuleLoaded() {};
        this._onModuleAborted = onModuleAborted || function onModuleAborted(abortedModuleName) {
            module.isRoot() || module.abort(isBundleQueue, abortedModuleName);
        };
    }

    LoaderQueue.prototype = {
        constructor: LoaderQueue,

        loadModules: function(moduleNames) {
            var loaderQueue = this,
                module = loaderQueue._module,
                logger = module.logger,
                loader = module.loader,
                isBundleQueue = loaderQueue._isBundleQueue,
                listenerName = module.getName(isBundleQueue);

            logger.log(isBundleQueue ? MSG_BUNDLE_SUBSCRIBED : MSG_MODULE_SUBSCRIBED, {
                subs: moduleNames.join(SEPERATOR)
            });

            loaderQueue._total += moduleNames.length;

            arrayEach(moduleNames, function loadModule(moduleName) {
                var isBundle = Resolver.isBundle(moduleName);

                loader.getModule(moduleName).request(isBundle).onLoad(InterceptionManager.intercept(loader, listenerName, moduleName, function onModuleLoaded(publishingModuleName, data) {
                    var percentageLoaded = Number((loaderQueue._counter++/loaderQueue._total).toFixed(2));

                    logger.log(isBundleQueue ? MSG_BUNDLE_NOTIFIED : MSG_MODULE_NOTIFIED, {
                        pub: publishingModuleName
                    });

                    loaderQueue._onModuleLoaded(publishingModuleName, data, percentageLoaded);
                    loaderQueue._callIfLoaded();
                }, loaderQueue._onModuleAborted), loaderQueue._onModuleAborted, isBundle);
            });

            !loaderQueue._total && loaderQueue._callIfLoaded();
        },

        _callIfLoaded: function() {
            var loaderQueue = this;

            if(loaderQueue._counter === loaderQueue._total) {
                loaderQueue._onModulesLoaded();
            }
        }
    };

    return LoaderQueue;
});
{'fraction_non_alphanumeric': 0.09740569791500875, 'fraction_numerical': 0.0009549578226961642, 'mean_word_length': 2.4565456545654567, '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': '2240783', 'n_tokens_mistral': 1728, 'n_tokens_neox': 1671, 'n_words': 267}