MCPcopy Index your code
hub / github.com/webpack/webpack / _forEachLevelFilter

Method _forEachLevelFilter

lib/stats/StatsFactory.js:222–237  ·  view source on GitHub ↗

* For each level filter. * @template {StatsFactoryHooks[keyof StatsFactoryHooks]} T * @template {T extends HookMap ? H : never} H * @template [D=EXPECTED_ANY] * @param {T} hookMap hook map * @param {Caches } cache cache * @param {string} type type * @param {D[]} items items

(hookMap, cache, type, items, fn, forceClone)

Source from the content-addressed store, hash-verified

220 * @private
221 */
222 _forEachLevelFilter(hookMap, cache, type, items, fn, forceClone) {
223 const hooks = this._getAllLevelHooks(hookMap, cache, type);
224 if (hooks.length === 0) return forceClone ? [...items] : items;
225 let i = 0;
226 return items.filter((item, idx) => {
227 for (const hook of hooks) {
228 const r = fn(/** @type {H} */ (hook), item, idx, i);
229 if (r !== undefined) {
230 if (r) i++;
231 return r;
232 }
233 }
234 i++;
235 return true;
236 });
237 }
238
239 /**
240 * Returns created object.

Callers 1

_createMethod · 0.95

Calls 2

_getAllLevelHooksMethod · 0.95
fnFunction · 0.50

Tested by

no test coverage detected