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

@tobes31415/dependency-injection

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tobes31415/dependency-injection - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

index-1.html

2

package.json
{
"name": "@tobes31415/dependency-injection",
"version": "1.0.0",
"version": "1.0.1",
"description": "Tiny dependency injection",

@@ -5,0 +5,0 @@ "main": "lib/di.min.js",

@@ -10,25 +10,19 @@ # DI

# Basic Useage
import { onDispose, dispose } from "@tobes31415/dispose"
onDispose(foo, () => {
//release resources
//disconnect from servers, etc
});
dispose(foo);
import { DI } from "@tobes31415/dependency-injection";
import { SomeService } from "./someService";
class SomeClass {
constructor() {
this.service = DI.resolve(SomeService);
}
}
# Advanced Useage
import { isDisposed, assertNotDisposed, createDisposeableFunctionWrapper, dispose } from "@tobes31415/dispose"
DI.useClass(Potato, Carrot);
const obj = DI.resolve(Potato) // instance of Carrot
if (isDisposed(foo)) {
foo = new Foo();
}
DI.useObject(Potato, {banana});
const obj = DI.resolve(Potato) // {banana}
assertNotDisposed(bar); //throws exception if bar has been disposed
const baz = createDisposeableFunctionWrapper( (a,b,c) => a * b + c );
baz(1,2,3) //outputs 5
dispose(baz);
baz(1,2,3) // throws an exception
DI.useFactory(Potato, () => 123);
const obj = DI.resolve(Potato) //123
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