Fork a child process and inject dependency
I currently have an operation in a module that is blocking, so I'm looking at making this into a child process that I fork instead. If I want to do that, then I of course need to modify the architecture of my module. The module requires that a dependency is injected by calling the module as a function, passing in the dependency, like so: var dependency = { name: "Bob" } require('worker')(dependency) Then in my worker module: module.exports = function (dependency) { // Outputs { name: "Bob" } console.log(dependency) } How can I turn this example into a child process being forked? When using