tapable
Advanced tools
Comparing version 2.1.1 to 2.2.0
@@ -14,3 +14,3 @@ /* | ||
code += `var _results = new Array(${this.options.taps.length});\n`; | ||
code += "var _checkDone = () => {\n"; | ||
code += "var _checkDone = function() {\n"; | ||
code += "for(var i = 0; i < _results.length; i++) {\n"; | ||
@@ -17,0 +17,0 @@ code += "var item = _results[i];\n"; |
@@ -58,3 +58,4 @@ /* | ||
code += '"use strict";\n'; | ||
code += "return new Promise((_resolve, _reject) => {\n"; | ||
code += this.header(); | ||
code += "return new Promise((function(_resolve, _reject) {\n"; | ||
if (errorHelperUsed) { | ||
@@ -64,3 +65,4 @@ code += "var _sync = true;\n"; | ||
code += "if(_sync)\n"; | ||
code += "_resolve(Promise.resolve().then(() => { throw _err; }));\n"; | ||
code += | ||
"_resolve(Promise.resolve().then((function() { throw _err; })));\n"; | ||
code += "else\n"; | ||
@@ -70,3 +72,2 @@ code += "_reject(_err);\n"; | ||
} | ||
code += this.header(); | ||
code += content; | ||
@@ -76,3 +77,3 @@ if (errorHelperUsed) { | ||
} | ||
code += "});\n"; | ||
code += "}));\n"; | ||
fn = new Function(this.args(), code); | ||
@@ -107,3 +108,12 @@ break; | ||
const onDone = options.onDone; | ||
return this.content( | ||
let code = ""; | ||
for (let i = 0; i < this.options.interceptors.length; i++) { | ||
const interceptor = this.options.interceptors[i]; | ||
if (interceptor.call) { | ||
code += `${this.getInterceptor(i)}.call(${this.args({ | ||
before: interceptor.context ? "_context" : undefined | ||
})});\n`; | ||
} | ||
} | ||
code += this.content( | ||
Object.assign(options, { | ||
@@ -151,2 +161,3 @@ onError: | ||
); | ||
return code; | ||
} else { | ||
@@ -169,10 +180,2 @@ return this.content(options); | ||
} | ||
for (let i = 0; i < this.options.interceptors.length; i++) { | ||
const interceptor = this.options.interceptors[i]; | ||
if (interceptor.call) { | ||
code += `${this.getInterceptor(i)}.call(${this.args({ | ||
before: interceptor.context ? "_context" : undefined | ||
})});\n`; | ||
} | ||
} | ||
return code; | ||
@@ -237,4 +240,5 @@ } | ||
let cbCode = ""; | ||
if (onResult) cbCode += `(_err${tapIndex}, _result${tapIndex}) => {\n`; | ||
else cbCode += `_err${tapIndex} => {\n`; | ||
if (onResult) | ||
cbCode += `(function(_err${tapIndex}, _result${tapIndex}) {\n`; | ||
else cbCode += `(function(_err${tapIndex}) {\n`; | ||
cbCode += `if(_err${tapIndex}) {\n`; | ||
@@ -250,3 +254,3 @@ cbCode += onError(`_err${tapIndex}`); | ||
cbCode += "}\n"; | ||
cbCode += "}"; | ||
cbCode += "})"; | ||
code += `_fn${tapIndex}(${this.args({ | ||
@@ -264,3 +268,3 @@ before: tap.context ? "_context" : undefined, | ||
code += ` throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise${tapIndex} + ')');\n`; | ||
code += `_promise${tapIndex}.then(_result${tapIndex} => {\n`; | ||
code += `_promise${tapIndex}.then((function(_result${tapIndex}) {\n`; | ||
code += `_hasResult${tapIndex} = true;\n`; | ||
@@ -273,3 +277,3 @@ if (onResult) { | ||
} | ||
code += `}, _err${tapIndex} => {\n`; | ||
code += `}), function(_err${tapIndex}) {\n`; | ||
code += `if(_hasResult${tapIndex}) throw _err${tapIndex};\n`; | ||
@@ -336,3 +340,3 @@ code += onError(`_err${tapIndex}`); | ||
if (!syncOnly) { | ||
code += "var _looper = () => {\n"; | ||
code += "var _looper = (function() {\n"; | ||
code += "var _loopAsync = false;\n"; | ||
@@ -378,3 +382,3 @@ } | ||
code += "_loopAsync = true;\n"; | ||
code += "};\n"; | ||
code += "});\n"; | ||
code += "_looper();\n"; | ||
@@ -404,5 +408,5 @@ } | ||
if (onDone) { | ||
code += "var _done = () => {\n"; | ||
code += "var _done = (function() {\n"; | ||
code += onDone(); | ||
code += "};\n"; | ||
code += "});\n"; | ||
} | ||
@@ -409,0 +413,0 @@ for (let i = 0; i < this.options.taps.length; i++) { |
{ | ||
"name": "tapable", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"author": "Tobias Koppers @sokra", | ||
@@ -30,2 +30,5 @@ "description": "Just a little module for plugins.", | ||
"types": "./tapable.d.ts", | ||
"browser": { | ||
"util": "./lib/util-browser.js" | ||
}, | ||
"scripts": { | ||
@@ -32,0 +35,0 @@ "test": "jest", |
46875
20
1241