Childseat allows you to interact with child processes using functions and callbacks. Childseat's fork() function produces the same ChildProcess produced by node's child_process.fork() function, except that you can attach function calls to it.
Childseat detects whether it has been required in a parent or child process and behaves accordingly.
var Childseat = require'childseat';var childFunction arg1 arg2 callback// Do somethingconsole.log"I receieved " + arg1 + " and " + arg2 + " from my parent!";var result = arg1 + arg2;callbackresult;Childseatadd'childFunction' childFunction;
var Childseat = require'childseat';var child = Childseatfork'child.js';// Child processes take some time to spin up, as per node's child_process documentationsetTimeoutchildchildFunctionvalue1 value2console.log"I received " + results + " from my child!";expectresulttoequalvalue1 + value2;;1000;