lib/cerus.js

1.
/**
2.
 * This is the core cerus class. This "function" will return an object with some functions 
3.
 * pre-added to it. This object can be seen as the CerusJS core. When adding plugins to cerus they 
4.
 * are added to this abject. For this functionality two functions have been pre-added to the object
5.
 * .plugins() and .use(). Both help you with managing the plugins. For more information about 
6.
 * plugins you can read the tutorial about it.
7.
 * @class cerus
8.
 * @nofunction
9.
 */
10.
module.exports = function() {
11.
	const cerus = {};
12.
	const plugins = new (require("./plugins"))(cerus);
13.

			
14.
	/**
15.
	 * This function returns the plugin managing class. With this class you can not only add, but also
16.
	 * remove, list, clear, etc. your plugins.
17.
	 * @summary Returns the plugin managing class.
18.
	 * @return {Class} The plugins class.
19.
	 * @function plugins
20.
	 */
21.
	cerus.plugins = function() {
22.
		return plugins;
23.
	};
24.

			
25.
	/**
26.
	 * With this function you can easily add a new plugin to the core. It is basically a shortcut for 
27.
	 * .plugins().add(). This means this plugin will check and then add the plugin, exactly the same as
28.
	 * .plugins().add(). For more information about adding plugins, see {@link plugins.add}.
29.
	 * @example
30.
	 * // in this example a plugin is added to the cerus core
31.
	 * // plugin -> {
32.
	 * //   name: "example",
33.
	 * //   dependencies: []
34.
	 * // }
35.
	 * 
36.
	 * cerus.use(plugin);
37.
	 * // -> will add the plugin to the cerus core
38.
	 * @summary Adds a new plugin to the core.
39.
	 * @param {Object} plugin The plugin object that contains the plugin that will be added.
40.
	 * @function use
41.
	 */
42.
	cerus.use = function(plugin) {
43.
		plugins.add(plugin);
44.
	};
45.

			
46.
	return cerus;
47.
};
48.