
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
#Tokioc ##A very simple IOC container for NodeJS
###How to use ####Install tokioc npm install tokioc ####Get Tokioc container instance
var ioc = require('tokioc');
####Registration
Tokioc supports the registration of objects and constructors.
#####Object registration
var target = {
propA: 'propA'
};
ioc.register('objByNameSingleInstance', target);
#####Constructor registration
var Target = function () {
var self = this;
self.now = new Date();
};
ioc.register('objByNameCtor', Target);
####Customizable lifetime manager Tokioc comes by default with a simple instance manager which caches resolved instances. Lifetime managers can be customized for different purposes. Lifetime managers must support setInstance and getInstance methods.
/**
* Container lifetime manager
*/
var ContainerLifetimeResolutionManager = function () {
var _instances = {};
function setInstance(name, target) {
_instances[name] = target;
}
/**
* Gets instance by name
*/
function getInstance(name) {
return _instances[name];
}
this.setInstance = setInstance;
this.getInstance = getInstance;
};
Register a dependency with a custom lifetime manager:
ioc.register('objByNameCtor', Target, new CustomLifetimeManager());
####Dependencies
Dependencies can only be declared on constructor registrations. Declare dependencies this way:
var Obj1 = function (obj2) {
var self = this;
self.obj2 = obj2;
};
var Obj2 = function () {
var self = this;
};
ioc.register('objByNameCtor', Obj1);
ioc.register('objByNameCtor2', Obj2);
Obj1.$dependencies = ['objByNameCtor2'];
Keep in mind that the constructor dependencies are applied in the order of the $dependencies array. ####Resolution
Resolve using the resolve method:
ioc.resolve('objByRef5', function (instance) { /* Do what you will with the resolution */ });
FAQs
Another simple IOC
We found that tokioc 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.