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

Function resolveAsSetter

packages/context/src/inject.ts:454–470  ·  view source on GitHub ↗

* Resolver for `@inject.setter` * @param ctx * @param injection

(ctx: Context, injection: Injection)

Source from the content-addressed store, hash-verified

452 * @param injection
453 */
454function resolveAsSetter(ctx: Context, injection: Injection) {
455 const targetName = assertTargetType(injection, Function, 'Setter function');
456 const bindingSelector = injection.bindingSelector;
457 if (!isBindingAddress(bindingSelector)) {
458 throw new Error(
459 `@inject.setter (${targetName}) does not allow BindingFilter.`,
460 );
461 }
462 if (bindingSelector === '') {
463 throw new Error('Binding key is not set for @inject.setter');
464 }
465 // No resolution session should be propagated into the setter
466 return function setter(value: unknown) {
467 const binding = findOrCreateBindingForInjection(ctx, injection);
468 binding!.to(value);
469 };
470}
471
472function resolveAsBinding(
473 ctx: Context,

Callers

nothing calls this directly

Calls 4

isBindingAddressFunction · 0.90
assertTargetTypeFunction · 0.85
toMethod · 0.80

Tested by

no test coverage detected