Refactoring

This commit is contained in:
Jerry Kurian
2019-08-16 09:02:54 -04:00
parent 505fefeeb5
commit faac6134af
48 changed files with 84 additions and 72 deletions

14
src/functions/child.ts Normal file
View File

@@ -0,0 +1,14 @@
import { ChildProcess } from "child_process";
import { duplex } from "./baseFunctions";
/**
* Return a Duplex stream from a child process' stdin and stdout
* @param childProcess Child process from which to create duplex stream
*/
export function child(childProcess: ChildProcess) {
if (childProcess.stdin === null) {
throw new Error("childProcess.stdin is null");
} else if (childProcess.stdout === null) {
throw new Error("childProcess.stdout is null");
}
return duplex(childProcess.stdin, childProcess.stdout);
}