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 🙏

© 2024 – Pkg Stats / Ryan Hefner

tapable2

v0.2.8

Published

Just a little module for plugins.

Downloads

48

Readme

Tapable

var Tapable = require("tapable");

Tapable is a class for plugin binding and applying.

Just extend it.

function MyClass() {
	Tapable.call(this);
}

MyClass.prototype = Object.create(Tapable.prototype);

MyClass.prototype.method = function() {};

Or mix it in.

function MyClass2() {
	EventEmitter.call(this);
	Tapable.call(this);
}

MyClass2.prototype = Object.create(EventEmitter.prototype);
Tapable.mixin(MyClass2.prototype);

MyClass2.prototype.method = function() {};

Public functions

apply

void apply(plugins: Plugin...)

Attaches all plugins passed as arguments to the instance, by calling apply on them.

plugin

void plugin(names: string|string[], handler: Function)

names are the names (or a single name) of the plugin interfaces the class provides.

handler is a callback function. The signature depends on the class. this is the instance of the class.

Protected functions

applyPlugins

void applyPlugins(name: string, args: any...)

Synchronously applies all registered handlers for name. The handler functions are called with all args.

applyPluginsWaterfall

any applyPluginsWaterfall(name: string, init: any, args: any...)

Synchronously applies all registered handlers for name. The handler functions are called with the return value of the previous handler and all args. For the first handler init is used and the return value of the last handler is return by applyPluginsWaterfall

applyPluginsAsync

void applyPluginsAsync(
	name: string,
	args: any...,
	callback: (err?: Error) -> void
)

Asynchronously applies all registered handlers for name. The handler functions are called with all args and a callback function with the signature (err?: Error) -> void. The handler functions are called in order of registration.

callback is called after all handlers are called.

applyPluginsBailResult

any applyPluginsBailResult(name: string, args: any...)

Synchronously applies all registered handlers for name. The handler function are called with all args. If a handler function returns something !== undefined, the value is returned and no more handlers are applied.

applyPluginsAsyncWaterfall

applyPluginsAsyncWaterfall(
	name: string,
	init: any,
	callback: (err: Error, result: any) -> void
)

Asynchronously applies all registered handlers for name. The handler functions are called with the current value and a callback function with the signature (err: Error, nextValue: any) -> void. When called, nextValue is the current value for the next handler. The current value for the first handler is init. After all handlers are applied, callback is called with the last value. If any handler passes a value for err, the callback is called with this error and no more handlers are called.

applyPluginsAsyncSeries

applyPluginsAsyncSeries(
	name: string,
	args: any...,
	callback: (err: Error, result: any) -> void
)

Asynchronously applies all registered handlers for name. The handler functions are called with all args and a callback function with the signature (err: Error) -> void. The handlers are called in series, one at a time. After all handlers are applied, callback is called. If any handler passes a value for err, the callback is called with this error and no more handlers are called.

applyPluginsParallel

applyPluginsParallel(
	name: string,
	args: any...,
	callback: (err?: Error) -> void
)

Applies all registered handlers for name in parallel. The handler functions are called with all args and a callback function with the signature (err?: Error) -> void. The callback function is called when all handlers have called the callback without err. If any handler calls the callback with err, callback is invoked with this error and the other handlers are ignored.

applyPluginsParallelBailResult

applyPluginsParallelBailResult(
	name: string,
	args: any...,
	callback: (err: Error, result: any) -> void
)

Applies all registered handlers for name in parallel. The handler functions are called with all args and a callback function with the signature (err?: Error) -> void. Handler functions must call the callback. They can either pass an error, pass undefined, or pass a value. The first result (either error or value) which is not undefined is passed to the callback. The order is defined by registration, not by the speed of the handler function.

hasPlugins

hasPlugins(
	name: string
)

Returns true, if plugins are registered for this name.