* 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)
| 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. |
no test coverage detected