MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / createDecorator

Function createDecorator

packages/agent-core/src/di/instantiation.ts:65–96  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

63}
64
65export function createDecorator<T>(name: string): ServiceIdentifier<T> {
66 const existing = _util.serviceIds.get(name);
67 if (existing) {
68 return existing as ServiceIdentifier<T>;
69 }
70
71 const id = function serviceDecorator(
72 // eslint-disable-next-line @typescript-eslint/no-explicit-any
73 target: any,
74 _key: string | symbol | undefined,
75 index: number,
76 ): void {
77 if (arguments.length !== 3) {
78 throw new Error(
79 '@IServiceName-decorator can only be used to decorate a parameter',
80 );
81 }
82 storeServiceDependency(id, target, index);
83 } as unknown as ServiceIdentifier<T>;
84
85 Object.defineProperty(id, 'toString', {
86 value: function toString(): string {
87 return name;
88 },
89 enumerable: false,
90 writable: false,
91 configurable: false,
92 });
93
94 _util.serviceIds.set(name, id);
95 return id;
96}
97
98export function refineServiceDecorator<T1, T extends T1>(
99 serviceIdentifier: ServiceIdentifier<T1>,

Callers 15

cyclic.test.tsFile · 0.90
child.test.tsFile · 0.90
collection.test.tsFile · 0.90
decorator.test.tsFile · 0.90
delayed.test.tsFile · 0.90
extensions.test.tsFile · 0.90
approval.tsFile · 0.90
logger.tsFile · 0.90
prompt.tsFile · 0.90

Calls 3

storeServiceDependencyFunction · 0.85
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected