MCPcopy Create free account
hub / github.com/loopbackio/loopback-next / getBinding

Method getBinding

packages/context/src/context.ts:822–840  ·  view source on GitHub ↗
(
    key: BindingAddress<ValueType>,
    options?: {optional?: boolean},
  )

Source from the content-addressed store, hash-verified

820 ): Binding<ValueType> | undefined;
821
822 getBinding<ValueType>(
823 key: BindingAddress<ValueType>,
824 options?: {optional?: boolean},
825 ): Binding<ValueType> | undefined {
826 key = BindingKey.validate(key);
827 const binding = this.registry.get(key);
828 if (binding) {
829 return binding;
830 }
831
832 if (this._parent) {
833 return this._parent.getBinding<ValueType>(key, options);
834 }
835
836 if (options?.optional) return undefined;
837 throw new Error(
838 `The key '${key}' is not bound to any value in context ${this.name}`,
839 );
840 }
841
842 /**
843 * Find or create a binding for the given key

Callers 15

findOrCreateBindingMethod · 0.95
getValueOrPromiseMethod · 0.95
mainFunction · 0.95
component.unit.tsFile · 0.45
lifecycle.unit.tsFile · 0.45
expectNoteRepoToBeBoundFunction · 0.45
context.unit.tsFile · 0.45

Calls 2

validateMethod · 0.80
getMethod · 0.65

Tested by 2

expectNoteRepoToBeBoundFunction · 0.36
expectGeocoderToBeBoundFunction · 0.36