Socket
Socket
Sign inDemoInstall

tapable

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tapable - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

0

lib/index.js

@@ -0,0 +0,0 @@ /*

2

package.json
{
"name": "tapable",
"version": "1.1.0",
"version": "1.1.1",
"author": "Tobias Koppers @sokra",

@@ -5,0 +5,0 @@ "description": "Just a little module for plugins.",

# Tapable
The tapable packages exposes many Hook classes, which can be used to create hooks for plugins.
The tapable package expose many Hook classes, which can be used to create hooks for plugins.

@@ -19,2 +19,8 @@ ``` javascript

## Installation
``` shell
npm install --save tapable
```
## Usage

@@ -35,3 +41,3 @@

accelerate: new SyncHook(["newSpeed"]),
break: new SyncHook(),
brake: new SyncHook(),
calculateRoutes: new AsyncParallelHook(["source", "target", "routesList"])

@@ -51,3 +57,3 @@ };

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

@@ -63,3 +69,3 @@

For sync hooks `tap` is the only valid method to add a plugin. Async hooks also support async plugins:
For sync hooks, `tap` is the only valid method to add a plugin. Async hooks also support async plugins:

@@ -130,19 +136,19 @@ ``` js

* Basic hook (without “Waterfall”, “Bail” or “Loop” in its name). This hook simply calls every function it’s tapped with in a row.
* Basic hook (without “Waterfall”, “Bail” or “Loop” in its name). This hook simply calls every function it tapped in a row.
* __Waterfall__. A waterfall hook also calls each tapped function in a row. Unlike the basic hook, it passes a return value from each function to the next function.
* __Bail__. A bail hook allows exitting early. When any of the tapped function returns anything, the bail hook will stop executing the remaining ones.
* __Bail__. A bail hook allows exiting early. When any of the tapped function returns anything, the bail hook will stop executing the remaining ones.
* __Loop__. TODO
Additionally, hooks can be synchronous or asynchronous. To reflect this, there’re “Sync”, “AsyncSeries” and “AsyncParallel” hook classes:
Additionally, hooks can be synchronous or asynchronous. To reflect this, there’re “Sync”, “AsyncSeries”, and “AsyncParallel” hook classes:
* __Sync__. A sync hooks can only be tapped with synchronous functions (using `myHook.tap()`).
* __Sync__. A sync hook can only be tapped with synchronous functions (using `myHook.tap()`).
* __AsyncSeries__. Async-series hooks can be tapped with synchronous, callback-based and promise-based functions (using `myHook.tap()`, `myHook.tapAsync()` and `myHook.tapPromise()`). They call each async method in a row.
* __AsyncSeries__. An async-series hook can be tapped with synchronous, callback-based and promise-based functions (using `myHook.tap()`, `myHook.tapAsync()` and `myHook.tapPromise()`). They call each async method in a row.
* __AsyncParallel__. Async-parallel hooks can also be tapped with synchronous, callback-based and promise-based functions (using `myHook.tap()`, `myHook.tapAsync()` and `myHook.tapPromise()`). However, they run each async method in parallel.
* __AsyncParallel__. An async-parallel hook can also be tapped with synchronous, callback-based and promise-based functions (using `myHook.tap()`, `myHook.tapAsync()` and `myHook.tapPromise()`). However, they run each async method in parallel.
The hook type is reflected in its class name. E.g., `AsyncSeriesWaterfallHook` allows asynchronous functions and runs them in series passing each function’s return value into the next function.
The hook type is reflected in its class name. E.g., `AsyncSeriesWaterfallHook` allows asynchronous functions and runs them in series, passing each function’s return value into the next function.

@@ -161,3 +167,3 @@

// tapInfo = { type: "promise", name: "GoogleMapsPlugin", fn: ... }
console.log(`${tapInfo.name} is doing it's job`);
console.log(`${tapInfo.name} is doing its job`);
return tapInfo; // may return a new tapInfo object

@@ -164,0 +170,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc