Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Mar 16, 2024 via pnpm

tapable 2.2.1

Just a little module for plugins.
Package summary
Share
0
issues
1
license
1
MIT
Package created
21 Jan 2013
Version published
13 Sep 2021
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
tapable@2.2.1
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of tapable 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does tapable do?

Tapable is a.package in JavaScript that exposes a number of Hook classes specifically designed for creating plugin hooks. This enables developers to register functions (termed as plugins) at specific points in an application's pipeline, effectively enabling custom logic to be executed at these crucial points. These hooks can be created synchronously or asynchronously and in different modes such as Waterfall, Bail, or Loop.

How do you use tapable?

To use the Tapable package, you first need to install it using npm.

npm install --save tapable

Then, import the required Hooks from the Tapable package.

const {
	SyncHook,
	SyncBailHook,
	SyncWaterfallHook,
	SyncLoopHook,
	AsyncParallelHook,
	AsyncParallelBailHook,
	AsyncSeriesHook,
	AsyncSeriesBailHook,
	AsyncSeriesWaterfallHook
 } = require("tapable");

You can then create a new instance of a Hook. Here, we create an instance of SyncHook:

const hook = new SyncHook(["arg1", "arg2", "arg3"]);

In practice, it is common to create all hooks in an object for an application, as follows:

class Car {
	constructor() {
		this.hooks = {
			accelerate: new SyncHook(["newSpeed"]),
			brake: new SyncHook(),
			calculateRoutes: new AsyncParallelHook(["source", "target", "routesList"])
		};
	}
	/* ... */
}

Once your hooks are set up, you can 'tap' into them at any point in your application to run custom logic:

const myCar = new Car();

// Use the tap method to add a consumer
myCar.hooks.brake.tap("WarningLampPlugin", () => warningLamp.on());

Where are the tapable docs?

The Tapable documentation is contained within the readme file of its GitHub repository. It offers a comprehensive overview of the Hook classes, how to use them, different types of hooks (sync, async, promise) and how to intercept calls amongst others. The documentation also includes example code snippets to illustrate usage. For implementing complex tasks, other than basic documentation, developers should refer to the source code and tests present in the repository.