Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@exosite/ziras-di
Advanced tools
Minimal Dependency Injection
Di.global
is a singleton of the Di class.
Register your dependency to a di instance.
Di.global.YourDependency = YourDepedency;
Di.global.yourDependency = new YourDependency();
Di.global.yourDependency = (...args) => new YourDependency(...args);
Apply a Di instance to your class. It applies to both itself and its prototype.
import Di from '@exosite/ziras-di';
class YourClass {}
Di.global(YourClass);
Use dependency depending on how it's registered.
import Di from '@exosite/ziras-di';
class YourClass {
static factory() {
this.yourDependency = new this.di.YourDependency();
this.yourDependency = this.di.yourDependency;
this.yourDependency = this.di.yourDependency();
}
constructor() {
this.yourDependency = new this.di.YourDependency();
this.yourDependency = this.di.yourDependency;
this.yourDependency = this.di.yourDependency();
}
}
Di.global(YourClass);
Create a Di instance and register services.
const di = new Di({
YourDependency,
yourDependency: new YourDependency(),
yourDependency(...args) {
return new YourDependency(...args);
}
});
Of course you can still do the old-school way. But it's not recommended.
const di = new Di();
di.YourDependency = YourDepedency;
di.yourDependency = new YourDependency();
di.yourDependency = (...args) => new YourDependency(...args);
Test a Di'ed class with a different Di instance.
const di = new Di();
const SubclassYourClass = di.extends(YourClass);
// Test against SubclassYourClass
The reason a subclass is created and tested against is so that the original class isn't modified and this should prevent us from making mistakes, e.g. forgot to re-apply the original Di instance to the original class.
Apply di to an object is also possible.
const yourObject = {};
Di.global(yourObject);
Run test in Node.js
npm test -- watch
Run test in browser
npm start
MIT
FAQs
Minimal Dependency Injection
The npm package @exosite/ziras-di receives a total of 181 weekly downloads. As such, @exosite/ziras-di popularity was classified as not popular.
We found that @exosite/ziras-di demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.