* Get all level hooks. * @template {StatsFactoryHooks[keyof StatsFactoryHooks]} HM * @template {HM extends HookMap<infer H> ? H : never} H * @param {HM} hookMap hook map * @param {Caches<H>} cache cache * @param {string} type type * @returns {H[]} hooks * @private
(hookMap, cache, type)
| 150 | * @private |
| 151 | */ |
| 152 | _getAllLevelHooks(hookMap, cache, type) { |
| 153 | const cacheEntry = cache.get(type); |
| 154 | if (cacheEntry !== undefined) { |
| 155 | return cacheEntry; |
| 156 | } |
| 157 | const hooks = /** @type {H[]} */ ([]); |
| 158 | const typeParts = type.split("."); |
| 159 | for (let i = 0; i < typeParts.length; i++) { |
| 160 | const hook = /** @type {H} */ (hookMap.get(typeParts.slice(i).join("."))); |
| 161 | if (hook) { |
| 162 | hooks.push(hook); |
| 163 | } |
| 164 | } |
| 165 | cache.set(type, hooks); |
| 166 | return hooks; |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Returns hook. |
no test coverage detected