
Security News
White House Authorizes Private Companies to Conduct Offensive Cyber Operations
A new federal program will let vetted U.S. cybersecurity firms help investigate and disrupt foreign cybercrime groups under government direction.
Injectly is a lightweight dependency injector based on Angular 2's dependency injection system.
Similar to angular, Injectly uses providers to store different types of values into the DI container. Injectly supports classes, factory functions and arbitrary values.
bindProvider(provider: Provider);
bind(name: string, dependencies: string[], config?: IInjectableConfig);
resolve<T>(name: string): T;
inject(dependencyNames: string[], callback: any;
import {Injector} from 'injectly';
let injector = new Injector();
injector.bindProvider(new Provider('Value', {
useValue: "Hello World"
}));
injector.bindProvider(new Provider('function', {
useValue: () => { return 5; }
}));
import {Provider} from 'injectly';
injector.bindProvider(new Provider('LogFactory', {
dependencies: ['Value'],
useFactory: (value) => {
console.log(`LogFactory: ${value}`); // Hello World
return value;
}
}));
import {Injectable} from 'injectly';
// Using decorators
@injector.bind('A', [])
class A {
constructor() {
console.log('A was instantiated');
}
}
// Create singletons by specifiying useExisting
@injector.bind('B', ['A'], { useExisting: true })
class B {
constructor(a: A) {
console.log('Test was instantiated with', A);
}
}
// Without decorators
class A {
constructor() {
console.log('A was instantiated');
}
}
injector.bindProvider(new Provider('A', {
useClass: A
}));
class B {
constructor(a: A) {
console.log('Test was instantiated with', A);
}
}
injector.bindProvider(new Provider('B', {
dependencies: ['A'],
useExisting: B
}));
// Get dependency from container
let B = injector.resolve<B>('B');
// Inject dependencies into a callback
injector.inject(['A', 'B'], (a, b) => {
console.log(a); // A { }
console.log(b); // B { }
});
FAQs
Lightweight dependency injector
The npm package injectly receives a total of 5 weekly downloads. As such, injectly popularity was classified as not popular.
We found that injectly demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
A new federal program will let vetted U.S. cybersecurity firms help investigate and disrupt foreign cybercrime groups under government direction.

Research
/Security News
The campaign amassed more than 75,000 installs by targeting Russian-speaking users seeking access to blocked services.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.