<commit_before>;(function(Plugins, Utils) { 'use strict';

    Plugins.fn = [];
    Plugins.registered = [];
    Plugins.loaded = [];
    Plugins.DEFAULTS = {};

    // Register plugins callback
    // -------------------------

    Plugins.load = function(pluginsList, context) {
        Plugins.registered = pluginsList;
        if (typeof pluginsList.forEach === 'function') {
            pluginsList.forEach(function(pluginName) {
                Plugins.call(pluginName, context);
            });
        } else {
            throw new Error('"Plugins" option on Planner.js should be a list of string');
        }
    };

    Plugins.register = function(pluginName, fn) {
        // During plugin registration, store all plugins DEFAULTS so it's fast to
        // reuse them during instance creation
        Plugins.DEFAULTS = Utils.extend({}, Plugins.DEFAULTS, fn.DEFAULTS);
        Plugins.fn[pluginName] = fn;
    };

    Plugins.call = function(pluginName, context, params) {
        var fn = Plugins.fn[pluginName];

        if (typeof fn === 'function') {
            context.plugins = context.plugins || {};
            context.plugins[pluginName] = new (fn.bind(context, context.element, context.options, params));
            Plugins.loaded[pluginName] = true;
        } else {
            throw new Error('Chosen plugin is not available: ' + pluginName);
        }
    };

    Plugins.isRegistered = function(pluginName) {
        return Plugins.registered.indexOf(pluginName) !== -1;
    };

    Plugins.requires = function(pluginName) {
        if (!Plugins.loaded[pluginName]) {
            throw new Error('"' + pluginName + '" plugin is required.');
        }

        return true;
    };

})(Planner.Plugins = Planner.Plugins || {}, Planner.Utils);
<commit_msg>minor refactoring of plugin manager<commit_after>;(function(Plugins, Utils) { 'use strict';

    Plugins.DEFAULTS = {};
    Plugins.registry = {};
    Plugins.loaded = {};

    // Register plugins callback
    // -------------------------

    Plugins.load = function(pluginsList, context) {
        if (Array.isArray(pluginsList)) {
            for (var i = 0; i < pluginsList.length; i++) {
                Plugins.call(pluginsList[i], context);
            }
        } else {
            throw new Error('"Plugins" option on Planner.js should be a list of string');
        }
    };

    Plugins.register = function(pluginName, fn) {
        // During plugin registration, store all plugins DEFAULTS so it's fast to
        // reuse them during instance creation
        Plugins.DEFAULTS = Utils.extend({}, Plugins.DEFAULTS, fn.DEFAULTS);
        Plugins.registry[pluginName] = fn;
    };

    Plugins.call = function(pluginName, context, params) {
        var fn = Plugins.registry[pluginName];

        if (typeof fn === 'function') {
            context.plugins = context.plugins || {};
            context.plugins[pluginName] = new (fn.bind(context, context.element, context.options, params));
            Plugins.loaded[pluginName] = true;
        } else {
            throw new Error('Chosen plugin is not available: ' + pluginName);
        }
    };

    // TODO: check the instance and not the registry
    Plugins.isRegistered = function(pluginName) {
        return typeof Plugins.registry[pluginName] !== 'undefined';
    };

  // TODO: check the instance and not the registry
    Plugins.requires = function(pluginName) {
        if (!Plugins.loaded[pluginName]) {
            throw new Error('"' + pluginName + '" plugin is required.');
        }

        return true;
    };

})(Planner.Plugins = Planner.Plugins || {}, Planner.Utils);

{'fraction_non_alphanumeric': 0.1397139713971397, 'fraction_numerical': 0.00055005500550055, 'mean_word_length': 2.2271517302573205, 'pattern_counts': {'":': 0, '<': 4, '<?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': '7189076', 'n_tokens_mistral': 1011, 'n_tokens_neox': 988, 'n_words': 246}