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

Function resolveContext

packages/context/src/resolver.ts:96–119  ·  view source on GitHub ↗

* If the scope of current binding is `SINGLETON`, reset the context * to be the one that owns the current binding to make sure a singleton * does not have dependencies injected from child contexts unless the * injection is for method (excluding constructor) parameters.

(
  ctx: Context,
  injection: Readonly<Injection>,
  session?: ResolutionSession,
)

Source from the content-addressed store, hash-verified

94 * injection is for method (excluding constructor) parameters.
95 */
96function resolveContext(
97 ctx: Context,
98 injection: Readonly<Injection>,
99 session?: ResolutionSession,
100) {
101 const currentBinding = session?.currentBinding;
102 if (currentBinding == null) {
103 // No current binding
104 return ctx;
105 }
106
107 const isConstructorOrPropertyInjection =
108 // constructor injection
109 !injection.member ||
110 // property injection
111 typeof injection.methodDescriptorOrParameterIndex !== 'number';
112
113 if (isConstructorOrPropertyInjection) {
114 // Set context to the resolution context of the current binding for
115 // constructor or property injections against a singleton
116 ctx = ctx.getResolutionContext(currentBinding)!;
117 }
118 return ctx;
119}
120
121/**
122 * Resolve the value or promise for a given injection

Callers 1

resolveFunction · 0.85

Calls 1

getResolutionContextMethod · 0.45

Tested by

no test coverage detected