Comparing version 4.0.0-rc.2 to 4.0.0-rc-10
{ | ||
"name": "cheap-di", | ||
"description": "TypeScript dependency injection like Autofac in .Net", | ||
"version": "4.0.0-rc.2", | ||
"version": "4.0.0-rc-10", | ||
"scripts": { | ||
@@ -18,4 +18,8 @@ "compile": "tsc --build tsconfig.cjs.json ./tsconfig.esm.json ./tsconfig.types.json", | ||
"rimraf": "5.0.5", | ||
"@types/jest": "29.5.8", | ||
"jest": "29.7.0", | ||
"ts-jest": "29.1.1", | ||
"ts-node": "10.9.1" | ||
}, | ||
"files": ["dist/**/*", ",package.json", "README.md"], | ||
"main": "./dist/cjs/index.js", | ||
@@ -26,7 +30,7 @@ "module": "./dist/esm/index.js", | ||
"type": "git", | ||
"url": "git+https://github.com/TomasLight/cheap-di.git" | ||
"url": "git+https://github.com/tomas-light/cheap-di.git" | ||
}, | ||
"author": "TomasLight", | ||
"license": "MIT", | ||
"homepage": "https://github.com/TomasLight/cheap-di#readme", | ||
"homepage": "https://github.com/tomas-light/cheap-di#readme", | ||
"keywords": [ | ||
@@ -33,0 +37,0 @@ "dependency", |
@@ -36,20 +36,2 @@ # cheap-di | ||
* With cheap-di-ts-transform here will be added information about Service dependencies. | ||
* It will looks like: | ||
* @example | ||
* import { findOrCreateMetadata } from 'cheap-di'; | ||
* | ||
* // for Logger | ||
* try { | ||
* const metadata = findOrCreateMetadata(Logger); | ||
* | ||
* // only classes may be instantiated with DI, other parameters can be filled with argument injection | ||
* metadata.dependencies = ["unknown"]; | ||
* } catch {} | ||
* | ||
* // for Service | ||
* try { | ||
* const metadata = findOrCreateMetadata(Service); | ||
* | ||
* metadata.dependencies = [Logger]; | ||
* } catch {} | ||
* */ | ||
@@ -61,3 +43,3 @@ | ||
const myLogPrefix = 'INFO: '; | ||
container.registerType(ConsoleLogger).as(Logger).with(myLogPrefix); | ||
container.registerImplementation(ConsoleLogger).as(Logger).inject(myLogPrefix); | ||
@@ -97,2 +79,3 @@ // somewhere in inside your code | ||
@inject(InfoLogger) | ||
class Service { | ||
@@ -110,6 +93,6 @@ constructor(private logger: InfoLogger) {} | ||
const infoPrefix = 'INFO: '; | ||
container.registerType(ConsoleLogger).as(InfoLogger).with(infoPrefix); | ||
container.registerImplementation(ConsoleLogger).as(InfoLogger).inject(infoPrefix); | ||
const errorPrefix = 'ERROR: '; | ||
container.registerType(ConsoleLogger).as(ErrorLogger).with(errorPrefix); | ||
container.registerImplementation(ConsoleLogger).as(ErrorLogger).inject(errorPrefix); | ||
@@ -124,2 +107,14 @@ // somewhere in inside your code | ||
To use stage 2 decorators you need to adjust your tsconfig.json like: | ||
```json | ||
{ | ||
"compilerOptions": { | ||
// ... | ||
"experimentalDecorators": true | ||
} | ||
} | ||
``` | ||
To use stage 3 decorators you don't need extra setup. | ||
## <a name="registration-variants"></a> Registration variants | ||
@@ -126,0 +121,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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
226257
64
2251
6
209
1