(self: Context<any>, key: string)
| 529 | const notFound = Symbol() |
| 530 | |
| 531 | const lookup = (self: Context<any>, key: string): unknown => { |
| 532 | const impl = self as ContextImpl<any> |
| 533 | for (let overlay = impl.overlay; overlay; overlay = overlay.parent) { |
| 534 | if (overlay.key === key) return overlay.value |
| 535 | } |
| 536 | const value = impl.base.get(key) |
| 537 | // Misses must not advance the counter: reference-default lookups miss the |
| 538 | // base on every fiber cache refresh, which would flatten every short-lived |
| 539 | // request context and reintroduce the O(services) per-request cost |
| 540 | if (value === undefined && !impl.base.has(key)) return notFound |
| 541 | if (impl.overlay && ++impl.baseHits >= FlattenAfterBaseHits) { |
| 542 | impl.base = flatten(impl) |
| 543 | impl.overlay = undefined |
| 544 | impl.depth = 0 |
| 545 | } |
| 546 | return value |
| 547 | } |
| 548 | |
| 549 | /** |
| 550 | * Creates a `Context` from an existing service map. |
no test coverage detected