sflow
Version:
sflow is a powerful and highly-extensible library designed for processing and manipulating streams of data effortlessly. Inspired by the functional programming paradigm, it provides a rich set of utilities for transforming streams, including chunking, fil
37 lines (35 loc) • 996 B
text/typescript
import {
fromReadable,
fromStdioDropErr,
fromStdioMergeError,
fromWritable,
} from "from-node-stream";
import { Readable, Writable } from "stream";
export { fromReadable, fromWritable };
/** Make TransformStream from stdio
* @deprecated import {fromStdio} from 'from-node-stream'
*/
export function fromStdio(
/** a process, which has stdin, stdout, stderr */
p: {
stdin?: Writable | null;
stdout?: Readable | null;
stderr?: Readable | null;
},
{
stderr = process.stderr,
}: {
// input stderr will pipe to this stream, defaults to process.stderr if undefined
stderr?: Writable | "mergeIntoStdout";
} = {}
): TransformStream<string | Uint8Array, string | Uint8Array> {
if (p.stderr instanceof Readable && stderr instanceof Writable)
fromReadable(p.stderr).pipeTo(fromWritable(stderr), {
preventClose: true,
});
if (stderr === "mergeIntoStdout") {
return fromStdioMergeError(p);
} else {
return fromStdioDropErr(p);
}
}