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

Method runAsync

test/HookTester.test.js:425–1146  ·  view source on GitHub ↗
(result, type)

Source from the content-addressed store, hash-verified

423 }
424
425 async runAsync(result, type) {
426 {
427 const hook = this.createHook([], `${type}None`);
428 result[`${type}None`] = await this.gainResult((cb) => hook[type](cb));
429 }
430
431 {
432 const hook = this.createHook(["arg"], `${type}NoneWithArg`);
433 result[`${type}NoneWithArg`] = await this.gainResult((cb) =>
434 hook[type](42, cb)
435 );
436 }
437
438 {
439 const hook = this.createHook([], `${type}SingleSync`);
440 hook.tap("sync", () => {
441 result[`${type}SingleSyncCalled1`] = true;
442 return 42;
443 });
444 result[`${type}SingleSync`] = await this.gainResult((cb) =>
445 hook[type](cb)
446 );
447 }
448
449 {
450 const hook = this.createHook(["x"], `${type}SingleSyncWithArg`);
451 hook.tap("sync", (arg) => {
452 result[`${type}SingleSyncWithArgCalled1`] = arg;
453 return arg + 1;
454 });
455 result[`${type}SingleSyncWithArg`] = await this.gainResult((cb) =>
456 hook[type](42, cb)
457 );
458 }
459
460 {
461 const hook = this.createHook(["x"], `${type}SingleSyncWithArgNoReturn`);
462 hook.tap("sync", (arg) => {
463 result[`${type}SingleSyncWithArgNoReturnCalled1`] = arg;
464 });
465 result[`${type}SingleSyncWithArgNoReturn`] = await this.gainResult((cb) =>
466 hook[type](42, cb)
467 );
468 }
469
470 {
471 const hook = this.createHook([], `${type}MultipleSync`);
472 hook.tap("sync1", () => {
473 result[`${type}MultipleSyncCalled1`] = true;
474 return 42;
475 });
476 hook.tap("sync2", () => {
477 result[`${type}MultipleSyncCalled2`] = true;
478 return 43;
479 });
480 result[`${type}MultipleSync`] = await this.gainResult((cb) =>
481 hook[type](cb)
482 );

Callers 1

runMethod · 0.95

Calls 5

createHookMethod · 0.95
gainResultMethod · 0.95
tapMethod · 0.45
tapAsyncMethod · 0.45
tapPromiseMethod · 0.45

Tested by

no test coverage detected