ioc-service-container
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -8,2 +8,8 @@ # Changelog | ||
## [1.1.0] - 2020-02-16 | ||
### Changed | ||
* renamed `@injectViaId` to `@inject` so `@inject` can be used with an optional serviceId parameter | ||
## [1.0.0] - 2020-02-15 | ||
@@ -10,0 +16,0 @@ |
@@ -1,2 +0,1 @@ | ||
export declare function inject(target: Object, propertyKey: string): void; | ||
export declare function injectViaId(serviceId: string): (target: Object, propertyKey: string) => void; | ||
export declare function inject(serviceIdOrTarget: Object | string, propertyKey?: string): any; |
import ServiceContainer from './ServiceContainer'; | ||
export function inject(target, propertyKey) { | ||
redefineObject(target, propertyKey); | ||
export function inject(serviceIdOrTarget, propertyKey) { | ||
if (typeof serviceIdOrTarget === 'string') { | ||
return function (target, propertyKey) { | ||
redefineObject(target, propertyKey, serviceIdOrTarget); | ||
}; | ||
} | ||
redefineObject(serviceIdOrTarget, propertyKey); | ||
} | ||
export function injectViaId(serviceId) { | ||
return function (target, propertyKey) { | ||
redefineObject(target, propertyKey, serviceId); | ||
}; | ||
} | ||
function redefineObject(target, propertyKey, serviceId) { | ||
@@ -11,0 +11,0 @@ const getter = () => { |
{ | ||
"name": "ioc-service-container", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Lightweight ioc service container", | ||
@@ -10,3 +10,4 @@ "main": "dist/index.js", | ||
"example": "ts-node example/example.ts", | ||
"test": "jest" | ||
"test": "jest", | ||
"sonar": "sonar-scanner -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=mrcwbr -Dsonar.projectKey=ioc-service-container -Dsonar.sources=src -Dsonar.tests=tests" | ||
}, | ||
@@ -18,5 +19,6 @@ "author": "mrcwbr", | ||
"jest": "^26.6.3", | ||
"ts-jest": "^26.4.4", | ||
"ts-jest": "^26.5.1", | ||
"ts-node": "^9.1.1", | ||
"typescript": "^4.1.3" | ||
"typescript": "^4.1.5", | ||
"sonarqube-scanner": "^2.8.0" | ||
}, | ||
@@ -23,0 +25,0 @@ "files": [ |
# ioc-service-container | ||
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=mrcwbr_ioc-service-container&metric=code_smells)](https://sonarcloud.io/dashboard?id=mrcwbr_ioc-service-container) | ||
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=mrcwbr_ioc-service-container&metric=bugs)](https://sonarcloud.io/dashboard?id=mrcwbr_ioc-service-container) | ||
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ioc-service-container&metric=alert_status)](https://sonarcloud.io/dashboard?id=ioc-service-container) | ||
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=ioc-service-container&metric=bugs)](https://sonarcloud.io/dashboard?id=ioc-service-container) | ||
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=ioc-service-container&metric=code_smells)](https://sonarcloud.io/dashboard?id=ioc-service-container) | ||
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=ioc-service-container&metric=coverage)](https://sonarcloud.io/dashboard?id=ioc-service-container) | ||
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=ioc-service-container&metric=security_rating)](https://sonarcloud.io/dashboard?id=ioc-service-container) | ||
![min-size](https://badgen.net/bundlephobia/min/ioc-service-container) | ||
![min-size-g-zip](https://badgen.net/bundlephobia/minzip/ioc-service-container) | ||
![dependency-count](https://badgen.net/bundlephobia/dependency-count/ioc-service-container) | ||
![npm-version](https://badgen.net/npm/v/ioc-service-container) | ||
![ts-types](https://badgen.net/npm/types/ioc-service-container) | ||
@@ -9,3 +17,5 @@ This is a lightweight library for a service container written in TypeScript. | ||
<a href="https://www.buymeacoffee.com/Mrcwbr" target="_blank"> | ||
<img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" > | ||
<img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" | ||
alt="Buy Me A Coffee" | ||
style="height: 41px !important;width: 174px !important;box-shadow: 0 3px 2px 0 rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0 3px 2px 0 rgba(190, 190, 190, 0.5) !important;" > | ||
</a> | ||
@@ -59,3 +69,3 @@ | ||
@injectViaId(ServiceId.FooApi) | ||
@inject(ServiceId.FooApi) | ||
private readonly nameThisHowYouWant!: FooApi // If you don't want to name your property like the service id, use this decorator | ||
@@ -62,0 +72,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
8796
122
6
66