MCPcopy
hub / github.com/tsedio/tsed / Inject

Function Inject

packages/di/src/common/decorators/inject.ts:153–172  ·  view source on GitHub ↗
(
  token?: TokenProvider<T> | (() => TokenProvider<T>),
  opts: TransformInjectedProviderCB<T> | Partial<Omit<BindInjectablePropertyOpts<T>, "token">> = {}
)

Source from the content-addressed store, hash-verified

151 opts?: Partial<Omit<BindInjectablePropertyOpts<T>, "token">>
152): any;
153export function Inject<T = any>(
154 token?: TokenProvider<T> | (() => TokenProvider<T>),
155 opts: TransformInjectedProviderCB<T> | Partial<Omit<BindInjectablePropertyOpts<T>, "token">> = {}
156) {
157 opts = typeof opts === "function" ? {transform: opts} : opts;
158
159 return (target: Object, propertyKey: string | symbol | undefined, index?: number) => {
160 const bindingType = decoratorTypeOf([target, propertyKey, index]);
161
162 switch (bindingType) {
163 case DecoratorTypes.PARAM_CTOR:
164 if (token) {
165 setToken(token, {target, propertyKey, parameterIndex: index!});
166 }
167 break;
168 case DecoratorTypes.PROP:
169 bindInjectableProperty(target, propertyKey!, {...opts, token});
170 }
171 };
172}

Callers 15

ServerClass · 0.90
ServerClass · 0.90
ConsentInteractionClass · 0.90
LoginInteractionClass · 0.90
AbortInteractionClass · 0.90
ServerClass · 0.90
LoginLocalProtocolClass · 0.90
PassportModuleClass · 0.90
PassportMiddlewareClass · 0.90
ProtocolsServiceClass · 0.90
ServerClass · 0.90

Calls 3

decoratorTypeOfFunction · 0.85
setTokenFunction · 0.85
bindInjectablePropertyFunction · 0.85

Tested by 7

constructorMethod · 0.68
constructorMethod · 0.68
constructorMethod · 0.68
constructorMethod · 0.68
constructorMethod · 0.68
constructorMethod · 0.68
constructorMethod · 0.68