Comparing version 0.1.10 to 0.2.1
@@ -18,3 +18,3 @@ /* | ||
copyProperties(Tapable.prototype, pt); | ||
} | ||
}; | ||
@@ -25,6 +25,4 @@ Tapable.prototype.applyPlugins = function applyPlugins(name) { | ||
var plugins = this._plugins[name]; | ||
var old = this._currentPluginApply; | ||
for(this._currentPluginApply = 0; this._currentPluginApply < plugins.length; this._currentPluginApply++) | ||
plugins[this._currentPluginApply].apply(this, args); | ||
this._currentPluginApply = old; | ||
for(var i = 0; i < plugins.length; i++) | ||
plugins[i].apply(this, args); | ||
}; | ||
@@ -37,6 +35,4 @@ | ||
var current = init; | ||
var old = this._currentPluginApply; | ||
for(this._currentPluginApply = 0; this._currentPluginApply < plugins.length; this._currentPluginApply++) | ||
current = plugins[this._currentPluginApply].apply(this, [current].concat(args)); | ||
this._currentPluginApply = old; | ||
for(var i = 0; i < plugins.length; i++) | ||
current = plugins[i].apply(this, [current].concat(args)); | ||
return current; | ||
@@ -49,11 +45,8 @@ }; | ||
var plugins = this._plugins[name]; | ||
var old = this._currentPluginApply | ||
for(this._currentPluginApply = 0; this._currentPluginApply < plugins.length; this._currentPluginApply++) { | ||
var result = plugins[this._currentPluginApply].apply(this, args); | ||
for(var i = 0; i < plugins.length; i++) { | ||
var result = plugins[i].apply(this, args); | ||
if(typeof result !== "undefined") { | ||
this._currentPluginApply = old; | ||
return result; | ||
} | ||
} | ||
this._currentPluginApply = old; | ||
}; | ||
@@ -64,3 +57,3 @@ | ||
var callback = args.pop(); | ||
if(!this._plugins[name] || this._plugins[name].length == 0) return callback(); | ||
if(!this._plugins[name] || this._plugins[name].length === 0) return callback(); | ||
var plugins = this._plugins[name]; | ||
@@ -80,3 +73,3 @@ var i = 0; | ||
Tapable.prototype.applyPluginsAsyncWaterfall = function applyPluginsAsyncWaterfall(name, init, callback) { | ||
if(!this._plugins[name] || this._plugins[name].length == 0) return callback(null, init); | ||
if(!this._plugins[name] || this._plugins[name].length === 0) return callback(null, init); | ||
var plugins = this._plugins[name]; | ||
@@ -98,3 +91,3 @@ var i = 0; | ||
var callback = args.pop(); | ||
if(!this._plugins[name] || this._plugins[name].length == 0) return callback(); | ||
if(!this._plugins[name] || this._plugins[name].length === 0) return callback(); | ||
var plugins = this._plugins[name]; | ||
@@ -109,3 +102,3 @@ var remaining = plugins.length; | ||
remaining--; | ||
if(remaining == 0) { | ||
if(remaining === 0) { | ||
return callback(); | ||
@@ -122,4 +115,4 @@ } | ||
var args = Array.prototype.slice.call(arguments, 1); | ||
var callback = args[args.length-1]; | ||
if(!this._plugins[name] || this._plugins[name].length == 0) return callback(); | ||
var callback = args[args.length - 1]; | ||
if(!this._plugins[name] || this._plugins[name].length === 0) return callback(); | ||
var plugins = this._plugins[name]; | ||
@@ -130,3 +123,3 @@ var currentPos = plugins.length; | ||
for(var i = 0; i < plugins.length; i++) { | ||
args[args.length-1] = (function(i) { | ||
args[args.length - 1] = (function(i) { | ||
return copyProperties(callback, function(err, result) { | ||
@@ -143,3 +136,3 @@ if(i >= currentPos) return; // ignore | ||
} | ||
if(done.length == currentPos) { | ||
if(done.length === currentPos) { | ||
callback(currentError, currentResult); | ||
@@ -155,9 +148,2 @@ currentPos = 0; | ||
Tapable.prototype.restartApplyPlugins = function restartApplyPlugins() { | ||
if(typeof this._currentPluginApply !== "number") | ||
throw new Error("Tapable.prototype.restartApplyPlugins can only be used inside of any sync plugins application"); | ||
this._currentPluginApply = -1; | ||
}; | ||
Tapable.prototype.plugin = function plugin(name, fn) { | ||
@@ -164,0 +150,0 @@ if(Array.isArray(name)) { |
{ | ||
"name": "tapable", | ||
"version": "0.1.10", | ||
"version": "0.2.1", | ||
"author": "Tobias Koppers @sokra", | ||
@@ -5,0 +5,0 @@ "description": "Just a little module for plugins.", |
@@ -55,12 +55,2 @@ # Tapable | ||
### restartApplyPlugins | ||
``` javascript | ||
void restartApplyPlugins() | ||
``` | ||
Should only be called from a handler function. | ||
It restarts the process of applying handers. | ||
## Protected functions | ||
@@ -142,4 +132,2 @@ | ||
`restartApplyPlugins` cannot be used. | ||
### applyPluginsParallelBailResult | ||
@@ -156,3 +144,1 @@ | ||
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. | ||
`restartApplyPlugins` cannot be used. |
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
8
14205
276
142