
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
IoC is all about control, and basic-ioc
attempts to give all of that control to the user.
At the lowest level, basic-ioc
is just a wrapper around require()
Here is an example configuration:
some-app.js
const ioc = require('basic-ioc');
const path = require('path');
let container = ioc.initialize(path.resolve(__dirname, 'config.json'));
let myComponent = container.get('yourComponentId');
// do something magical with your component
config.json
{
"components": [
{
"id": "yourComponentId",
"source": "./your-component.js"
}
]
}
But this is just a contrived example. Most likely you want dependency injection. The following is more than likely what you are looking for.
config.json
{
"components": [
{
"id": "yourDependency",
"source": "./your-dependency.js"
},
{
"id": "yourComponentId",
"source": "./your-component.js",
"properties": [
{
"name": "myDependency",
"ref": "your-dependency.js"
}
]
}
]
}
In this case, your-component.js
declares a method on the exported object which is provided with the object exported via your-dependency.js
during initialization.
I needed an IoC container and I felt that many of the ones available on npm were very specific about how you build your code. I wanted to avoid that.
I also come from the Java community and thus, based the initial design of this module off of Spring.
FAQs
javascript inversion of control container
We found that basic-ioc 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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.