Files
strom/src/functions/child.ts
Jerry Kurian faac6134af Refactoring
2019-08-16 09:02:54 -04:00

15 lines
550 B
TypeScript

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);
}