( key: K, instance: BasePrototypeCache[K], accessor: T, )
| 136 | > = {}; |
| 137 | |
| 138 | export function getUntaintedAccessor< |
| 139 | K extends keyof BasePrototypeCache, |
| 140 | T extends keyof BasePrototypeCache[K], |
| 141 | >( |
| 142 | key: K, |
| 143 | instance: BasePrototypeCache[K], |
| 144 | accessor: T, |
| 145 | ): BasePrototypeCache[K][T] { |
| 146 | const cacheKey = `${key}.${String(accessor)}`; |
| 147 | if (untaintedAccessorCache[cacheKey]) |
| 148 | return untaintedAccessorCache[cacheKey].call( |
| 149 | instance, |
| 150 | ) as BasePrototypeCache[K][T]; |
| 151 | |
| 152 | const untaintedPrototype = getUntaintedPrototype(key); |
| 153 | // eslint-disable-next-line @typescript-eslint/unbound-method |
| 154 | const untaintedAccessor = Object.getOwnPropertyDescriptor( |
| 155 | untaintedPrototype, |
| 156 | accessor, |
| 157 | )?.get; |
| 158 | |
| 159 | if (!untaintedAccessor) return instance[accessor]; |
| 160 | |
| 161 | untaintedAccessorCache[cacheKey] = untaintedAccessor; |
| 162 | |
| 163 | return untaintedAccessor.call(instance) as BasePrototypeCache[K][T]; |
| 164 | } |
| 165 | |
| 166 | type BaseMethod<K extends keyof BasePrototypeCache> = ( |
| 167 | this: BasePrototypeCache[K], |
no test coverage detected