childprocess-messageport
Turns ChildProcess
IPC into MessagePort.
Background
Instead of learning/using different API for different communication channels, we should unite them into a single interface pattern, either MessagePort or WebSocket.
How to use
const childProcess = ChildProcess;const messagePort = childProcess; messagePort { // Could be either a string or Buffer console;}; messagePort;
Instead of subscribing to
onmessage
, you can also subscribe usingon('message', handler)
.
If the underlying childProcess.send
is failed, an error
event will be emitted.
Contributions
Like us? Star us.
Want to make it better? File us an issue.
Don't like something you see? Submit a pull request.