@inversifyjs/core
Version:
InversifyJs core package
30 lines • 1.25 kB
JavaScript
import { InversifyCoreError } from '../../error/models/InversifyCoreError.js';
import { InversifyCoreErrorKind } from '../../error/models/InversifyCoreErrorKind.js';
import { DecoratorInfoKind } from '../models/DecoratorInfoKind.js';
export function getDecoratorInfo(target, propertyKey, parameterIndexOrDescriptor) {
if (parameterIndexOrDescriptor === undefined) {
if (propertyKey === undefined) {
throw new InversifyCoreError(InversifyCoreErrorKind.unknown, 'Unexpected undefined property and index values');
}
return {
kind: DecoratorInfoKind.property,
property: propertyKey,
targetClass: target.constructor,
};
}
if (typeof parameterIndexOrDescriptor === 'number') {
return {
index: parameterIndexOrDescriptor,
kind: DecoratorInfoKind.parameter,
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
targetClass: target,
};
}
return {
kind: DecoratorInfoKind.method,
method: propertyKey,
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
targetClass: target,
};
}
//# sourceMappingURL=getDecoratorInfo.js.map