tapable
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -67,2 +67,19 @@ /* | ||
Tapable.prototype.applyPluginsAsyncSeriesBailResult = function applyPluginsAsyncSeriesBailResult(name) { | ||
var args = Array.prototype.slice.call(arguments, 1); | ||
var callback = args.pop(); | ||
if(!this._plugins[name] || this._plugins[name].length === 0) return callback(); | ||
var plugins = this._plugins[name]; | ||
var i = 0; | ||
args.push(copyProperties(callback, function next() { | ||
if(arguments.length > 0) return callback.apply(null, arguments); | ||
i++; | ||
if(i >= plugins.length) { | ||
return callback(); | ||
} | ||
plugins[i].apply(this, args); | ||
}.bind(this))); | ||
plugins[0].apply(this, args); | ||
}; | ||
Tapable.prototype.applyPluginsAsyncWaterfall = function applyPluginsAsyncWaterfall(name, init, callback) { | ||
@@ -112,10 +129,10 @@ if(!this._plugins[name] || this._plugins[name].length === 0) return callback(null, init); | ||
var currentPos = plugins.length; | ||
var currentError, currentResult; | ||
var currentResult; | ||
var done = []; | ||
for(var i = 0; i < plugins.length; i++) { | ||
args[args.length - 1] = (function(i) { | ||
return copyProperties(callback, function(err, result) { | ||
return copyProperties(callback, function() { | ||
if(i >= currentPos) return; // ignore | ||
done.push(i); | ||
if(err || result) { | ||
if(arguments.length > 0) { | ||
currentPos = i + 1; | ||
@@ -125,7 +142,6 @@ done = done.filter(function(item) { | ||
}); | ||
currentError = err; | ||
currentResult = result; | ||
currentResult = Array.prototype.slice.call(arguments); | ||
} | ||
if(done.length === currentPos) { | ||
callback(currentError, currentResult); | ||
callback.apply(null, currentResult); | ||
currentPos = 0; | ||
@@ -132,0 +148,0 @@ } |
{ | ||
"name": "tapable", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"author": "Tobias Koppers @sokra", | ||
@@ -5,0 +5,0 @@ "description": "Just a little module for plugins.", |
14766
291