MCPcopy
hub / github.com/webpack/webpack / makeInterceptorFor

Function makeInterceptorFor

lib/debug/ProfilingPlugin.js:504–523  ·  view source on GitHub ↗
(instance, tracer)

Source from the content-addressed store, hash-verified

502 * @returns {(hookName: string) => HookInterceptor<EXPECTED_ANY, EXPECTED_ANY>} interceptor
503 */
504const makeInterceptorFor = (instance, tracer) => (hookName) => ({
505 /**
506 * Returns modified full tap.
507 * @param {FullTap} tapInfo tap info
508 * @returns {FullTap} modified full tap
509 */
510 register: (tapInfo) => {
511 const { name, type, fn: internalFn } = tapInfo;
512 const newFn =
513 // Don't tap our own hooks to ensure stream can close cleanly
514 name === PLUGIN_NAME
515 ? internalFn
516 : makeNewProfiledTapFn(hookName, tracer, {
517 name,
518 type,
519 fn: /** @type {PluginFunction} */ (internalFn)
520 });
521 return { ...tapInfo, fn: newFn };
522 }
523});
524
525/**
526 * Creates new profiled tap fn.

Callers 2

applyMethod · 0.85
interceptAllHooksForFunction · 0.85

Calls 1

makeNewProfiledTapFnFunction · 0.85

Tested by

no test coverage detected