MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / getOwnerContext

Method getOwnerContext

packages/context/src/context.ts:482–505  ·  view source on GitHub ↗

* Get the owning context for a binding or its key * @param keyOrBinding - Binding object or key

(
    keyOrBinding: BindingAddress | Readonly<Binding<unknown>>,
  )

Source from the content-addressed store, hash-verified

480 * @param keyOrBinding - Binding object or key
481 */
482 getOwnerContext(
483 keyOrBinding: BindingAddress | Readonly<Binding<unknown>>,
484 ): Context | undefined {
485 let key: BindingAddress;
486 if (keyOrBinding instanceof Binding) {
487 key = keyOrBinding.key;
488 } else {
489 key = keyOrBinding as BindingAddress;
490 }
491 if (this.contains(key)) {
492 if (keyOrBinding instanceof Binding) {
493 // Check if the contained binding is the same
494 if (this.registry.get(key.toString()) === keyOrBinding) {
495 return this;
496 }
497 return undefined;
498 }
499 return this;
500 }
501 if (this._parent) {
502 return this._parent.getOwnerContext(key);
503 }
504 return undefined;
505 }
506
507 /**
508 * Get the context matching the scope

Callers 4

getResolutionContextMethod · 0.95
getResolutionContextMethod · 0.80
context.unit.tsFile · 0.80
logContextsFunction · 0.80

Calls 3

containsMethod · 0.95
getMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected