Creates a Plugger instance from a JSON file asynchronously.
Path to the JSON file, or to a directory that contains a 'package.json' file.
Specifies which properties to be included as the metadata of the instance.
A Promise that resolves to a new Plugger instance.
Creates a Plugger instance from a JSON file synchronously.
Path to the JSON file, or to a directory that contains a 'package.json' file.
Specifies which properties to be included as the metadata of the instance.
A new Plugger
instance.
Creates a Plugger instance.
The name of the instance.
Contains custom error classes.
The metadata of the instance.
Returns the name of the instance that is stored in instance.metadata.name
.
The name of the instance.
Plugin behavior configurations.
Returns the context of the instance.
This context is exclusive to the instance only and directly mutable. Note that the context is not the state of the instance. It is designed to be used internally by the instance.
The context of the instance.
Returns the list of required plugins and their metadata.
A list of metadata.
Removes a plugin from the instance's required plugins.
The name of the plugin.
The current instance.
Adds metadata
as a required plugin for the instance.
A loader will check if a plugin with the same metadata is loaded and initialized first before
trying to initialize the instance. The property 'version'
of metadata
and its nested
objects supports semantic versioning syntax.
The metadata of the plugin.
The current instance.
Checks whether the instance requires a plugin or not.
The metadata of the plugin.
true
if the instance requires the plugin, false
if not.
Returns the state of the instance
Returns the status of the instance
Returns whether the instance is initialized or not.
Runs the init
callback function.
Runs the shutdown
callback function.
Function to be run subsequently.
The return value of the function
Returns all loaded plugins.
An array of Plugger instances.
Returns the requested plugin.
The name of the plugin.
A Plugger instance, or null if not found.
Loads the plugin to the instance.
The plugin that you want to load.
The load order priority of the plugin.
The current instance.
Removes the plugin from the instance.
The plugin that you want to remove/unload.
The current instance.
Returns the load order of the instance.
All loaded plugins, sorted to their load order.
Sorts the load order of the instance.
Plugins that are required by other plugins are set to initialize first. Their priorities are also taken into consideration.
The current instance.
Returns wheter the plugin is loaded by the instance or not.
true if the plugin is loaded by the instance, else false.
Loads all packages in a directory that directly exports a Plugger instance asynchronously.
dir
is the path to the directory, relative to proccess.cwd()
. Any other packages that
doesn't export a Plugger instance will be silently ignored.
The path to the directory.
A Promise that resolves to the current instance.
Loads all packages in a directory that directly exports a Plugger instance synchronously.
dir
is the path to the directory, relative to proccess.cwd()
. Any other packages that
doesn't export a Plugger instance will be silently ignored.
The path to the directory.
The current instance.
Initializes the plugin asynchronously.
The plugin that you want to initialize.
A Promise that resolves to the current instance.
Initializes all loaded plugins asynchronously in parallel.
A Promise that resolves to the current instance.
Shuts down the plugin asynchronously.
The plugin that you want to shutdown.
A Promise that resolves to the current instance.
Shuts down all loaded plugins asynchronously in parallel.
A Promise that resolves to the current instance.
Adds an event listener that shuts down all loaded plugins when the process is exiting.
This will run a function that executes instance.shutdownAll()
when an exit event signal is
emitted by process
. It is recommended to only run this method on your main loader instance,
as to not pollute the event with many listeners (NodeJS limited the number of listeners to
10 per event by default). Running this method multiple times on the same instance won't
register multiple listeners.
The current instance.
Removes the attached event listener from the process.
Running this method without running attachExitListener()
first won't do anything.
Generated using TypeDoc
Some common terms:
Plugger: the main class that can act as both a plugin and a loader.
Plugin: a
Plugger
instance that acts as a plugin.Loader: a
Plugger
instance that acts as a loader.Loaded plugin: a plugin that has been added/loaded to a loader by using the
addPlugin()
function.Initialized plugin: a plugin that has been initialized by a loader by using the
initPlugin()
function.