Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cheap-di

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cheap-di - npm Package Compare versions

Comparing version 4.0.0-rc.2 to 4.0.0-rc-10

dist/cjs/__tests/ContainerImpl.test.js

10

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc