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

Method runSync

test/HookTester.test.js:247–423  ·  view source on GitHub ↗
(result, method)

Source from the content-addressed store, hash-verified

245 }
246
247 async runSync(result, method) {
248 {
249 const hook = this.createHook([], `${method}None`);
250 result[`${method}None`] = await this.gainResult((cb) => hook[method](cb));
251 }
252
253 {
254 const hook = this.createHook(["arg"], `${method}NoneWithArg`);
255 result[`${method}NoneWithArg`] = await this.gainResult((cb) =>
256 hook[method](42, cb)
257 );
258 }
259
260 {
261 const hook = this.createHook([], `${method}SingleSync`);
262 hook.tap("sync", () => {
263 result[`${method}SingleSyncCalled`] = true;
264 return 42;
265 });
266 result[`${method}SingleSync`] = await this.gainResult((cb) =>
267 hook[method](cb)
268 );
269 }
270
271 {
272 const hook = this.createHook(["myArg"], `${method}SingleSyncWithArg`);
273 hook.tap("sync", (nr) => {
274 result[`${method}SingleSyncWithArgCalled`] = nr;
275 return nr;
276 });
277 result[`${method}SingleSyncWithArg`] = await this.gainResult((cb) =>
278 hook[method](42, cb)
279 );
280 }
281
282 {
283 const hook = this.createHook([], `${method}MultipleSync`);
284 hook.tap("sync1", () => {
285 result[`${method}MultipleSyncCalled1`] = true;
286 return 42;
287 });
288 hook.tap("sync2", () => {
289 result[`${method}MultipleSyncCalled2`] = true;
290 return 43;
291 });
292 result[`${method}MultipleSync`] = await this.gainResult((cb) =>
293 hook[method](cb)
294 );
295 }
296
297 {
298 const hook = this.createHook(["a"], `${method}MultipleSyncWithArg`);
299 hook.tap("sync1", (a) => {
300 result[`${method}MultipleSyncWithArgCalled1`] = a;
301 return 42 + a;
302 });
303 hook.tap("sync2", (a) => {
304 result[`${method}MultipleSyncWithArgCalled2`] = a;

Callers 1

runMethod · 0.95

Calls 4

createHookMethod · 0.95
gainResultMethod · 0.95
tapMethod · 0.45
interceptMethod · 0.45

Tested by

no test coverage detected