Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cjus/xprocess
Create and manage external processes
https://github.com/cjus/xprocess
Last synced: about 1 month ago
JSON representation
Create and manage external processes
- Host: GitHub
- URL: https://github.com/cjus/xprocess
- Owner: cjus
- License: mit
- Created: 2016-09-09T10:53:21.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-05T04:19:12.000Z (almost 7 years ago)
- Last Synced: 2024-11-14T12:03:01.902Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# XProcess
An external process wrapper which uses events to communicate with its invoker.
## Sample usage
```javascript
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', () => {
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.
```