Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const Injectable = >>() => (target: T): any => {
injectable()(target)
const parameters = Reflect.getMetadata(METADATA_KEY.PARAM_TYPES, target)
for (let index = 0; index < parameters.length; index++) {
const parameter = parameters[index]
// only auto inject service
injectService(parameter, target, undefined, index)
}
}
return function (target: any) {
const isAlreadyDecorated = Reflect.hasOwnMetadata(inversify_METADATA_KEY.PARAM_TYPES, target);
const redecorateWithInject = force === true;
if (redecorateWithInject === true && isAlreadyDecorated === false) {
decorate(injectable(), target);
} else if (redecorateWithInject === true && isAlreadyDecorated === true) {
// Do nothing
} else {
try {
decorate(injectable(), target);
} catch (e) {
throw new Error(
"Cannot apply @fluentProvide decorator multiple times but is has been used " +
`multiple times in ${target.name} ` +
"Please use done(true) if you are trying to declare multiple bindings!"
);
}
function isInjectable(target) {
return (Reflect as any).hasOwnMetadata(METADATA_KEY.PARAM_TYPES, target);
}
.forEach(klass => {
Reflect.deleteMetadata(METADATA_KEY.PARAM_TYPES, klass);
Reflect.deleteMetadata(METADATA_KEY.TAGGED, klass);
});
}