MCPcopy
hub / github.com/webpack/tapable / callTapsLooping

Method callTapsLooping

lib/HookCodeFactory.js:337–387  ·  view source on GitHub ↗
({ onError, onDone, rethrowIfPossible })

Source from the content-addressed store, hash-verified

335 }
336
337 callTapsLooping({ onError, onDone, rethrowIfPossible }) {
338 if (this.options.taps.length === 0) return onDone();
339 const syncOnly = this.options.taps.every((t) => t.type === "sync");
340 let code = "";
341 if (!syncOnly) {
342 code += "var _looper = (function() {\n";
343 code += "var _loopAsync = false;\n";
344 }
345 code += "var _loop;\n";
346 code += "do {\n";
347 code += "_loop = false;\n";
348 for (let i = 0; i < this.options.interceptors.length; i++) {
349 const interceptor = this.options.interceptors[i];
350 if (interceptor.loop) {
351 code += `${this.getInterceptor(i)}.loop(${this.args({
352 before: interceptor.context ? "_context" : undefined
353 })});\n`;
354 }
355 }
356 code += this.callTapsSeries({
357 onError,
358 onResult: (i, result, next, doneBreak) => {
359 let code = "";
360 code += `if(${result} !== undefined) {\n`;
361 code += "_loop = true;\n";
362 if (!syncOnly) code += "if(_loopAsync) _looper();\n";
363 code += doneBreak(true);
364 code += "} else {\n";
365 code += next();
366 code += "}\n";
367 return code;
368 },
369 onDone:
370 onDone &&
371 (() => {
372 let code = "";
373 code += "if(!_loop) {\n";
374 code += onDone();
375 code += "}\n";
376 return code;
377 }),
378 rethrowIfPossible: rethrowIfPossible && syncOnly
379 });
380 code += "} while(_loop);\n";
381 if (!syncOnly) {
382 code += "_loopAsync = true;\n";
383 code += "});\n";
384 code += "_looper();\n";
385 }
386 return code;
387 }
388
389 callTapsParallel({
390 onError,

Callers 3

contentMethod · 0.80
contentMethod · 0.80

Calls 4

getInterceptorMethod · 0.95
argsMethod · 0.95
callTapsSeriesMethod · 0.95
nextFunction · 0.85

Tested by

no test coverage detected