MCPcopy
hub / github.com/webpack/webpack / createHooksRegistry

Function createHooksRegistry

lib/util/createHooksRegistry.js:16–33  ·  view source on GitHub ↗
(createHooks)

Source from the content-addressed store, hash-verified

14 * @returns {(compilation: import("../Compilation")) => T} getter that returns (or creates) hooks for the compilation
15 */
16const createHooksRegistry = (createHooks) => {
17 /** @type {WeakMap<import("../Compilation"), T>} */
18 const map = new WeakMap();
19 return (compilation) => {
20 const Compilation = getCompilation();
21 if (!(compilation instanceof Compilation)) {
22 throw new TypeError(
23 "The 'compilation' argument must be an instance of Compilation"
24 );
25 }
26 let hooks = map.get(compilation);
27 if (hooks === undefined) {
28 hooks = createHooks();
29 map.set(compilation, hooks);
30 }
31 return hooks;
32 };
33};
34
35module.exports = createHooksRegistry;

Calls 2

getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected