npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

alpha-module-manager

v1.0.36

Published

The Alpha Plugins Manager is a JavaScript utility for managing plugins in a web application. It consists of three main classes: Logger, PluginsRegistry, and AlphaPluginsManager, each serving a specific purpose.

Readme

ALPHA PLUGINS MANAGAR

The Alpha Plugins Manager is a JavaScript utility for managing plugins in a web application. It consists of three main classes: Logger, PluginsRegistry, and AlphaPluginsManager, each serving a specific purpose.

HOW TO USE

Initialization

A variable alpha is initialized globally, which has all the essential functions for the Alpha Plugins Manager, Logger and PluginsRegistry.

Registering a Plugin

Use the registerPlugins method to register a plugin with the Alpha Plugins Manager.

const myPlugin = {
    // ...plugin properties and methods...
    onRegister: () => {
        // Optional callback when the plugin is registered
        console.log('My plugin has been registered!');
    },
};
// Register the plugin with a unique name
alpha.registerPlugins('myPlugin', myPlugin);

Unregistering a Plugin

Use the deregisterPlugin method to unregister a previously registered plugin.

// Unregister the previously registered plugin by name
alpha.deregisterPlugin('myPlugin');

Subscribing to Events

Subscribe to application event lifecycle hooks using the on method.

// Subscribe to a custom event
const unsubscribe = alpha.on('customEvent', data => {
    console.log('Custom event triggered with data:', data);
});

// Later, to unsubscribe
unsubscribe();

Triggering Events

Trigger application events using the trigger method.

// Trigger a custom event with data
alpha.trigger('customEvent', { key: 'value' });

Unsubscribing from Events

Use the off method to unsubscribe from an application event lifecycle hook.

// Define a callback function
const customEventHandler = data => {
    console.log('Custom event triggered with data:', data);
};

// Subscribe to a custom event
const unsubscribe = alpha.on('customEvent', customEventHandler);

// Later, to unsubscribe and stop receiving events
alpha.off('customEvent', customEventHandler);

Accessing Registered Plugins

Retrieve the list of registered plugins using the plugins property.

// Get the list of registered plugins
const registeredPlugins = alpha.plugins;
console.log('Registered Plugins:', registeredPlugins);

Accessing Functions of a Plugin

const myPlugin = {
    // ...plugin properties and methods...
    onRegister: () => {
        // Optional callback when the plugin is registered
        console.log('My plugin has been registered!');
    },
};
// Accessing plugin functions
alpha.plugins.myPlugin.onRegister();

BASE-SERVICE DOCUMENTATION

Logger Class

The Logger class provides a versatile logging mechanism with customizable styles. It supports both logging and error messages, playing a crucial role in providing informative output throughout the plugin manager.

Methods

  • constructor(label = "[Logger]") Description: Initializes a new Logger instance with an optional label. Parameters: label (optional): Custom label for the logger. Default is "[Logger]".
  • log(...args) Description: Logs messages to the console with the specified label and style. Parameters: args: Any number of arguments to be logged.
  • error(...args) Description: Logs error messages to the console with the specified label and style. Parameters: args: Any number of arguments to be logged as an error.

PluginsRegistry Class

The PluginsRegistry class acts as a registry for managing plugins. It allows the addition, removal, and retrieval of plugins, providing error handling for scenarios such as duplicate or nonexistent plugins.

Methods

  • add(name, instance) Description: Adds a new plugin to the registry. Parameters: name: Unique name of the plugin. instance: The plugin instance to be added. Returns: true if the addition is successful.
  • remove(name) Description: Removes a plugin from the registry. Parameters: name: Unique name of the plugin to be removed. Returns: The removed plugin instance if successful.
  • get(name) Description: Retrieves a plugin from the registry. Parameters: name: Unique name of the plugin to be retrieved. Returns: The plugin instance if found.

AlphaPluginsManager Class

The AlphaPluginsManager class orchestrates the registration and unregistration of plugins. Additionally, it provides an event system for communication between different parts of the application and dispatches an "alpha_ready" event when the application is ready.

Methods

  • constructor(logger, registry) Initializes a new AlphaPluginsManager instance with a logger and a plugin registry. Parameters: logger: An instance of the Logger class for logging messages. registry: An instance of the PluginsRegistry class for managing plugins.

  • onReady(callback) Registers a callback to be executed when the application is ready. Parameters: callback: The function to be executed on readiness.

  • registerPlugins(name, instance) Registers a plugin with the AlphaPluginsManager. Parameters: name: Unique name of the plugin. instance: The plugin instance to be registered.

  • deregisterPlugin(name) Unregisters a plugin from the AlphaPluginsManager. Parameters: name: Unique name of the plugin to be unregistered.

  • on(eventName, fn) Subscribes to an App event lifecycle hook. Parameters: eventName: Unique name of the event. fn: The function to be executed on the event. Returns: A function for unsubscribing from the event.

  • trigger(eventName, data) Publishes/triggers an App event lifecycle hook. Parameters: eventName: Unique name of the event. data: Data to be passed to the event handlers.

  • off(eventName, fn) Unsubscribes from an App event lifecycle hook. Parameters: eventName: Unique name of the event. fn: The function to be unsubscribed.

  • get plugins() Retrieves the list of registered plugins.

Initialization

The provided code initializes the Logger, PluginsRegistry, and AlphaPluginsManager instances. It also dispatches an "alpha_ready" event after a short delay to signal that the application is ready.

const logger = new Logger('[AlphaPluginsManager]');
const registry = new PluginsRegistry(logger);
const alpha = new AlphaPluginsManager(logger, registry);

// Simulating the readiness of the application
setTimeout(() => {
    const alphaReadyEvent = new Event('alpha_ready');
    window.dispatchEvent(alphaReadyEvent);
}, 0);