<commit_before>
import redboxWrapper from './redboxWrapper'
import { destroyPlugin, destroy } from './destroy'


/**
 * @param {object}
 */
export default function createCreateInstance(PluginApi) {

	/**
	 * @param {object}
	 * @param {object}
	 * @return {object}
	 */
	return function createInstance(pluginObj, createPlugin) {
		pluginObj.plugin = createPlugin;
		pluginObj.hotReload = function(newPlugin) {
			redboxWrapper(pluginObj, () => destroyPlugin(pluginObj, newPlugin!==null));

			pluginObj.plugin = newPlugin===null ? null : (newPlugin || pluginObj.plugin);
			pluginObj.pluginApi = undefined;
			pluginObj.api = function(name) {};
			pluginObj.instances = [];

			pluginObj.plugin && redboxWrapper(pluginObj, function() {
				const pluginApi = new PluginApi({
					$element: pluginObj.$element,
					pluginName: pluginObj.pluginName,
					pluginId: pluginObj.pluginId,
					pluginObj: pluginObj,
					state: pluginObj.state,
					name: pluginObj.name,
				}, pluginObj.hotReload);

				pluginObj.pluginApi = pluginApi;
				pluginObj.api = pluginApi.eachApi.bind(pluginApi);
				pluginObj.pluginApi.createInstance = function(createPlugin, plugin) {
					plugin = plugin || pluginObj.pluginArgumentsObj;
					plugin = {...plugin}
<commit_msg>Add pluginObj.reload method<commit_after>
import redboxWrapper from './redboxWrapper'
import { destroyPlugin, destroy } from './destroy'


/**
 * @param {object}
 */
export default function createCreateInstance(PluginApi) {

	/**
	 * @param {object}
	 * @param {object}
	 * @return {object}
	 */
	return function createInstance(pluginObj, createPlugin) {
		pluginObj.plugin = createPlugin;
		pluginObj.reload = function() {
			pluginObj.reloadData && pluginObj.reloadData();
			pluginObj.hotReload();
		}
		pluginObj.hotReload = function(newPlugin) {
			redboxWrapper(pluginObj, () => destroyPlugin(pluginObj, newPlugin!==null));

			pluginObj.plugin = newPlugin===null ? null : (newPlugin || pluginObj.plugin);
			pluginObj.pluginApi = undefined;
			pluginObj.api = function(name) {};
			pluginObj.instances = [];

			pluginObj.plugin && redboxWrapper(pluginObj, function() {
				const pluginApi = new PluginApi({
					$element: pluginObj.$element,
					pluginName: pluginObj.pluginName,
					pluginId: pluginObj.pluginId,
					pluginObj: pluginObj,
					state: pluginObj.state,
					name: pluginObj.name,
				}, pluginObj.hotReload);

				pluginObj.pluginApi = pluginApi;
				pluginObj.api = pluginApi.eachApi.bind(pluginApi);
				pluginObj.pluginApi.createInstance = function(createPlugin, plugin) {
					plugin = plugin || pluginObj.pluginArgumentsObj;
					plugin = {...plugin}

{'fraction_non_alphanumeric': 0.12817595752749336, 'fraction_numerical': 0.0, 'mean_word_length': 4.122330097087379, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '88397', 'n_tokens_mistral': 918, 'n_tokens_neox': 765, 'n_words': 157}