Fuxor
Very simple DI for node.
const fuxor = require('fuxor');
fuxor.add('fs', {
readFileSync: function () {
return 'Not really a file';
}
});
const fs = require('fs');
console.log(fs.readFileSync('not really', 'anything', { whatever:'you want'}));
API
Add
const fuxor = require('fuxor');
fuxor.add('fs', {
readFileSync: function () {
return 'Not really a file';
}
});
fuxor.add({ name: 'fs', result: {
readFileSync: function () {
return 'Not really a file';
}
}});
fuxor.add([{ name: 'fs', result: {
readFileSync: function () {
return 'Not really a file';
}
}, {
name: 'request',
result: function () {
return 'Not really a file';
}
}]);
Clear
const fuxor = require('fuxor');
fuxor.clear();
remove
const fuxor = require('fuxor');
fuxor.remove('your-module');
reset
const fuxor = require('fuxor');
fuxor.reset();