xprocess

2.0.0 • Public • Published

XProcess

An external process wrapper which uses events to communicate with its invoker.

Sample usage

const XProcess = require('xprocess');
let xProcess = XProcess.createClient();
xProcess.run('node', './child.js');
 
xProcess.send({
  text: 'Hey child, wake up it\'s time for school!'
});
xProcess.on('message', (msg) => {
  console.log(`Child: ${msg.text}`);
});
xProcess.on('disconnect', () => console.log('Child disconnected'));
xProcess.on('exit', () => console.log('Child exit'));
xProcess.on('close', () => {
xProcess.on('close', () => {
  console.log('Parent: Okay, child is in class - I\'m off to work where I\'ll deal with bigger kids.');
});

Sample test

Run parent.js in test folder:

$ node parent.js
Parent: Hey child, wake up it's time for school!
Child: Hey mom, five more minutes?
Child: Okay, okay, I'm getting getting up right now!
Child: What's for breakfast?
Child: Mom, where are my jeans?
Child: Can I get 10 bucks for lunch?
Child: I'm late for school can you drive me?
Child: Thanks mom see you at 3pm.
Child disconnected
Child exit
Parent: Okay, child is in class - I'm off to work where I'll deal with bigger kids.

Readme

Keywords

Package Sidebar

Install

npm i xprocess

Weekly Downloads

3

Version

2.0.0

License

MIT

Unpacked Size

9.54 kB

Total Files

9

Last publish

Collaborators

  • cjus