Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@travetto/exec

Package Overview
Dependencies
Maintainers
1
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@travetto/exec - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

src/pool/array.ts

3

package.json

@@ -8,2 +8,3 @@ {

"@travetto/base": "0.x.x",
"@travetto/pool": "0.x.x",
"@types/cross-spawn": "^6.0.0",

@@ -19,3 +20,3 @@ "cross-spawn": "^6.0.5"

},
"version": "0.0.5"
"version": "0.0.6"
}

@@ -42,3 +42,4 @@ import * as child_process from 'child_process';

}
super.kill();
}
}

@@ -98,4 +98,10 @@ import { CommonProcess, ExecutionEvent } from './types';

kill() {
this.clean();
delete this._proc;
}
get pid() {
return this._proc && this._proc.pid;
}
clean() {

@@ -102,0 +108,0 @@ if (this._proc) {

@@ -18,2 +18,3 @@ import * as child_process from 'child_process';

export interface CommonProcess {
pid: number;
send?(message: any, sendHandle?: any): void;

@@ -20,0 +21,0 @@ removeListener(name: string, f: Function): void;

@@ -1,29 +0,33 @@

import { ChildExecution, ExecutionPool } from '../src';
import { ChildExecution, ExecutionPool, ArrayDataSource, IteratorDataSource } from '../src';
const pool = new ExecutionPool<ChildExecution>({
count: 1,
create() {
const child = new ChildExecution(`${__dirname}/index.js`, true, {
env: { SRC: './simple.child' }
});
child.init();
(child as any)['ready'] = child.listenOnce('ready');
return child;
const pool = new ExecutionPool<ChildExecution>(async () => {
console.log('Initializing child');
const child = new ChildExecution(`${__dirname}/index.js`, true, {
env: { SRC: './simple.child' }
});
child.init();
await child.listenOnce('ready');
console.log('Child ready');
return child;
},
async init(child: ChildExecution) {
await (child as any)['ready'];
return child;
},
async exec(inp: string, child: ChildExecution) {
const wait = child.listenOnce('response');
child.send('request', { data: inp });
const res = await wait;
console.log('Sent', inp, 'Received', res);
}, { max: 1 });
pool.process(
// new ArrayDataSource(['a', 'b', 'c', 'd', 'e', 'f', 'g']),
new IteratorDataSource(function* () {
for (let i = 0; i < 10; i++) {
yield `${i}-`;
}
}),
async (i: string, exe: ChildExecution) => {
const res = exe.listenOnce('response');
exe.send('request', { data: i });
const { data } = await res;
console.log('Sent', i, 'Received', data);
await new Promise(r => setTimeout(r, 1000));
}
});
pool.process(['a', 'b', 'c', 'd', 'e', 'f', 'g']).then(() => {
).then(async () => {
console.log('DONE!');
pool.shutdown();
await pool.shutdown();
process.exit(0);
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc