MCPcopy
hub / github.com/webpack/webpack / _getAllLevelHooks

Method _getAllLevelHooks

lib/stats/StatsPrinter.js:131–152  ·  view source on GitHub ↗

* get all level hooks * @private * @template {StatsPrintHooks[keyof StatsPrintHooks]} HM * @template {HM extends HookMap<infer H> ? H : never} H * @param {HM} hookMap hook map * @param {string} type type * @returns {H[]} hooks

(hookMap, type)

Source from the content-addressed store, hash-verified

129 * @returns {H[]} hooks
130 */
131 _getAllLevelHooks(hookMap, type) {
132 let cache = this._levelHookCache.get(hookMap);
133 if (cache === undefined) {
134 cache = new Map();
135 this._levelHookCache.set(hookMap, cache);
136 }
137 const cacheEntry = cache.get(type);
138 if (cacheEntry !== undefined) {
139 return /** @type {H[]} */ (cacheEntry);
140 }
141 /** @type {H[]} */
142 const hooks = [];
143 const typeParts = type.split(".");
144 for (let i = 0; i < typeParts.length; i++) {
145 const hook = /** @type {H} */ (hookMap.get(typeParts.slice(i).join(".")));
146 if (hook) {
147 hooks.push(hook);
148 }
149 }
150 cache.set(type, hooks);
151 return hooks;
152 }
153
154 /**
155 * Run `fn` for each level

Callers 2

_forEachLevelMethod · 0.95

Calls 5

splitMethod · 0.80
sliceMethod · 0.80
getMethod · 0.45
setMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected