
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
container-ioc
Advanced tools
import { Container, Inject } from 'container-ioc';
let container = new Container();
// Register classes:
class RandomClass1 {};
class RandomClass3 {
doSomething(): void {
console.log('hello world');
}
};
// Use Injector decorater to inject dependencies:
class RandomClass2 {
constructor(@Inject(RandomClass3) public instance3: any) {
}
};
// Register classes in the container:
// You can pass just a Class literal alone or a provider literal ->
// { token: 'string or class literal', useClass: 'class literal' }
let providers = [
RandomClass1,
{ token: 'anystring', useClass: RandomClass2 },
{ token: RandomClass3, useClass: RandomClass3 }
];
container.register(providers);
// Resolve instances
let instance1: RandomClass1 = container.resolve(RandomClass1);
let instance2: RandomClass2 = container.resolve('anystring');
instance2.instance3.doSomething(); // hello world
let Container = require('container-ioc').Container;
let container = new Container();
// Register classes:
class RandomClass1 {};
class RandomClass3 {
doSomething() {
console.log('hello world');
}
};
// Use Injector decorater to inject dependencies:
class RandomClass2 {
instance3;
constructor() {
this.instance3 = container.resolve(RandomClass3);
}
};
// Register classes in the container:
// You can pass just a Class literal alone or a provider literal ->
// { token: 'string or class literal', useClass: 'class literal' }
let providers = [
RandomClass1,
{ token: 'anystring', useClass: RandomClass2 },
{ token: RandomClass3, useClass: RandomClass3 }
];
container.register(providers);
// Resolve instances
let instance1 = container.resolve(RandomClass1);
let instance2 = container.resolve('anystring');
instance2.instance3.doSomething(); // hello world
if a provider wasn't found in a container it will look up in ascendant containers if there's any:
import { Container } from 'container-ioc';
class SomeClass {
doStuff(): void {
console.log('hello world');
}
}
let parentContainer = new Container();
let childContainer = parentContainer.createScope();
parentContainer.register({ token: 'ISome', useClass: SomeClass });
childContainer.resolve('ISome');
let instance = childContainer.resolve('ISome');
instance.doStuff(); // hello world
FAQs
Dependency Injection and Inversion of Control (IoC) container
The npm package container-ioc receives a total of 40 weekly downloads. As such, container-ioc popularity was classified as not popular.
We found that container-ioc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.