riot
Version:
Simple and elegant component-based UI library
21 lines (16 loc) • 664 B
JavaScript
/* Riot v10.1.2, @license MIT */
import { isFunction } from '../dependencies/@riotjs/util/checks.js';
import { PLUGINS_SET } from '../dependencies/@riotjs/util/constants.js';
import { panic } from '../dependencies/@riotjs/util/misc.js';
/**
* Define a riot plugin
* @param {Function} plugin - function that will receive all the components created
* @returns {Set} the set containing all the plugins installed
*/
function install(plugin) {
if (!isFunction(plugin)) panic('Plugins must be of type function');
if (PLUGINS_SET.has(plugin)) panic('This plugin was already installed');
PLUGINS_SET.add(plugin);
return PLUGINS_SET
}
export { install };