ioc-service-container
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -1,1 +0,1 @@ | ||
export declare const inject: (target: any, key: string) => void; | ||
export declare const inject: (target: Object, propertyKey: string) => void; |
import ServiceContainer from './ServiceContainer'; | ||
export const inject = (target, key) => { | ||
export const inject = (target, propertyKey) => { | ||
// todo further improvements set key as string not via name | ||
// https://dev.to/danywalls/using-property-decorators-in-typescript-with-a-real-example-44e | ||
const getter = () => { | ||
return ServiceContainer.get(key.toLocaleLowerCase()); | ||
return ServiceContainer.get(propertyKey.toLowerCase()); | ||
}; | ||
// @ts-ignore | ||
if (delete this[key]) { | ||
Object.defineProperty(target, key, { | ||
get: getter, | ||
set: undefined, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
} | ||
const setter = () => { | ||
throw new Error(`Injected property [${propertyKey}] can't be reset`); | ||
}; | ||
Object.defineProperty(target, propertyKey, { | ||
get: getter, | ||
set: setter | ||
}); | ||
}; |
{ | ||
"name": "ioc-service-container", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Lightweight ioc service container", | ||
@@ -21,6 +21,11 @@ "main": "dist/index.js", | ||
}, | ||
"files": [ | ||
"dist/*", | ||
"README.md", | ||
"Changelog.md" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git@gitlab.com:smscr/ja-container.git" | ||
"url": "https://github.com/mrcwbr/ioc-service-container" | ||
} | ||
} |
@@ -8,2 +8,7 @@ # ioc-service-container | ||
## Get started | ||
Install the dependency with `npm install ioc-service-container | ||
` | ||
## Background | ||
@@ -10,0 +15,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60
5293
11
60