| 233 | * @returns {string} the returned relative path |
| 234 | */ |
| 235 | const boundFn = (context, identifier) => { |
| 236 | /** @type {undefined | string} */ |
| 237 | let cachedResult; |
| 238 | let innerSubCache = innerCache.get(context); |
| 239 | if (innerSubCache === undefined) { |
| 240 | innerCache.set(context, (innerSubCache = new Map())); |
| 241 | } else { |
| 242 | cachedResult = innerSubCache.get(identifier); |
| 243 | } |
| 244 | |
| 245 | if (cachedResult !== undefined) { |
| 246 | return cachedResult; |
| 247 | } |
| 248 | const result = fn(context, identifier); |
| 249 | innerSubCache.set(identifier, result); |
| 250 | return result; |
| 251 | }; |
| 252 | |
| 253 | return boundFn; |
| 254 | }; |