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