Comparing version 0.2.6 to 0.2.7
@@ -87,7 +87,9 @@ /* | ||
if(!this._plugins[name]) return init; | ||
var args = Array.prototype.slice.call(arguments, 2); | ||
var args = Array.prototype.slice.call(arguments, 1); | ||
var plugins = this._plugins[name]; | ||
var current = init; | ||
for(var i = 0; i < plugins.length; i++) | ||
current = plugins[i].apply(this, [current].concat(args)); | ||
for(var i = 0; i < plugins.length; i++) { | ||
args[0] = current; | ||
current = plugins[i].apply(this, args); | ||
} | ||
return current; | ||
@@ -128,2 +130,46 @@ }; | ||
Tapable.prototype.applyPluginsBailResult2 = function applyPluginsBailResult2(name, param1, param2) { | ||
if(!this._plugins[name]) return; | ||
var plugins = this._plugins[name]; | ||
for(var i = 0; i < plugins.length; i++) { | ||
var result = plugins[i].call(this, param1, param2); | ||
if(typeof result !== "undefined") { | ||
return result; | ||
} | ||
} | ||
}; | ||
Tapable.prototype.applyPluginsBailResult3 = function applyPluginsBailResult3(name, param1, param2, param3) { | ||
if(!this._plugins[name]) return; | ||
var plugins = this._plugins[name]; | ||
for(var i = 0; i < plugins.length; i++) { | ||
var result = plugins[i].call(this, param1, param2, param3); | ||
if(typeof result !== "undefined") { | ||
return result; | ||
} | ||
} | ||
}; | ||
Tapable.prototype.applyPluginsBailResult4 = function applyPluginsBailResult4(name, param1, param2, param3, param4) { | ||
if(!this._plugins[name]) return; | ||
var plugins = this._plugins[name]; | ||
for(var i = 0; i < plugins.length; i++) { | ||
var result = plugins[i].call(this, param1, param2, param3, param4); | ||
if(typeof result !== "undefined") { | ||
return result; | ||
} | ||
} | ||
}; | ||
Tapable.prototype.applyPluginsBailResult5 = function applyPluginsBailResult5(name, param1, param2, param3, param4, param5) { | ||
if(!this._plugins[name]) return; | ||
var plugins = this._plugins[name]; | ||
for(var i = 0; i < plugins.length; i++) { | ||
var result = plugins[i].call(this, param1, param2, param3, param4, param5); | ||
if(typeof result !== "undefined") { | ||
return result; | ||
} | ||
} | ||
}; | ||
Tapable.prototype.applyPluginsAsyncSeries = Tapable.prototype.applyPluginsAsync = function applyPluginsAsyncSeries(name) { | ||
@@ -294,3 +340,8 @@ var args = Array.prototype.slice.call(arguments, 1); | ||
Tapable.prototype.hasPlugins = function hasPlugins(name) { | ||
var plugins = this._plugins[name]; | ||
return plugins && plugins.length > 0; | ||
}; | ||
Tapable.prototype.plugin = function plugin(name, fn) { | ||
@@ -297,0 +348,0 @@ if(Array.isArray(name)) { |
{ | ||
"name": "tapable", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"author": "Tobias Koppers @sokra", | ||
@@ -5,0 +5,0 @@ "description": "Just a little module for plugins.", |
@@ -63,3 +63,3 @@ # Tapable | ||
Synchronous applies all registered handers for `name`. The handler functions are called with all args. | ||
Synchronously applies all registered handlers for `name`. The handler functions are called with all args. | ||
@@ -72,3 +72,3 @@ ### applyPluginsWaterfall | ||
Synchronous applies all registered handers 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` | ||
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` | ||
@@ -85,3 +85,3 @@ ### applyPluginsAsync | ||
Asynchronously applies all registered handers for `name`. The handler functions are called with all args and a callback function with the signature `(err?: Error) -> void`. The hander functions are called in order of registration. | ||
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. | ||
@@ -96,3 +96,3 @@ `callback` is called after all handlers are called. | ||
Synchronous applies all registered handers for `name`. The handler function are called with all args. If a handler function returns something `!== undefined`, the value is returned and no more handers are applied. | ||
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. | ||
@@ -109,3 +109,3 @@ ### applyPluginsAsyncWaterfall | ||
Asynchronously applies all registered handers for `name`. The hander 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. | ||
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. | ||
@@ -122,3 +122,3 @@ ### applyPluginsAsyncSeries | ||
Asynchronously applies all registered handers for `name`. The hander functions are called with all `args` and a callback function with the signature `(err: Error) -> void`. The handers 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. | ||
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. | ||
@@ -135,3 +135,3 @@ ### applyPluginsParallel | ||
Applies all registered handlers for `name` 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 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. | ||
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. | ||
@@ -148,2 +148,12 @@ ### applyPluginsParallelBailResult | ||
Applies all registered handlers for `name` 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, or pass undefined, or pass an value. The first result (either error or value) with is not undefined is passed to the `callback`. The order is defined by registeration not by speed of the handler function. This function compentate this. | ||
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 | ||
``` js | ||
hasPlugins( | ||
name: string | ||
) | ||
``` | ||
Returns true, if plugins are registered for this name. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16457
326
152