microdi
A micro helper for JavaScript DI.
> npm install microdi
Imagine the following snippet.
const doSomething x => +
for testing purposes it's handy to be able stubbing either of moduleA
or moduleB
. This can be achieved with a bit different definition
// define module referring local varsconst doSomething = moduleA moduleB
and any dependencies can be injected as
const doSomething1 = doSomething // produced function is identical to original// so you can even do followingconst doSomething2 = doSomething1