UNPKG

from-node-stream

Version:
102 lines (97 loc) 4.89 kB
import { Duplex, Readable, Writable } from "stream"; //#region ts/fromReadable.d.ts /** * Converts a Node.js Readable stream to a Web API ReadableStream * @template T - The type of data being read (string or Uint8Array) * @param i - The Node.js readable stream to convert * @returns A Web API ReadableStream that wraps the Node.js stream */ declare function fromReadable<T extends string | Uint8Array>(i: Readable | NodeJS.ReadableStream | ReadableStream): ReadableStream<T>; //#endregion //#region ts/fromWritable.d.ts /** * Converts a Node.js Writable stream to a Web API WritableStream * @template T - The type of data being written (string or Uint8Array) * @param i - The Node.js writable stream to convert * @returns A Web API WritableStream that wraps the Node.js stream */ declare function fromWritable<T extends string | Uint8Array>(i: Writable | NodeJS.WritableStream | WritableStream): WritableStream<T>; //#endregion //#region ts/fromDuplex.d.ts /** * Converts a Node.js Duplex stream to a Web API TransformStream * @template IN - The type of data being written (string or Uint8Array) * @template OUT - The type of data being read (string or Uint8Array) * @param duplex - The Node.js duplex stream to convert * @returns A Web API TransformStream that wraps the Node.js duplex stream */ declare function fromDuplex<IN extends string | Uint8Array, OUT extends string | Uint8Array>(duplex: Duplex | TransformStream): TransformStream<IN, OUT>; //#endregion //#region ts/index.d.ts /** * Creates a TransformStream from a process's stdio, dropping stderr output * @template IN - Input data type (string or Uint8Array) * @template OUT - Output data type (string or Uint8Array) * @param p - A process object with stdin, stdout, and stderr streams * @returns A TransformStream that connects stdin to stdout, ignoring stderr */ declare function fromStdioDropErr<IN extends string | Uint8Array, OUT extends string | Uint8Array>(/** a process, which has stdin, stdout, stderr */ p: { stdin?: Writable | WritableStream | null; stdout?: Readable | ReadableStream | null; stderr?: Readable | ReadableStream | null; }): TransformStream<IN, OUT>; /** * Creates a TransformStream from a process's stdio, merging stdout and stderr * @template IN - Input data type (string or Uint8Array) * @template OUT - Output data type (string or Uint8Array) * @param p - A process object with stdin, stdout, and stderr streams * @returns A TransformStream that connects stdin to a merged stdout+stderr stream */ declare function fromStdioMergeError<IN extends string | Uint8Array, OUT extends string | Uint8Array>(/** a process, which has stdin, stdout, stderr */ p: { stdin?: Writable | WritableStream | null; stdout?: Readable | ReadableStream | null; stderr?: Readable | ReadableStream | null; }): TransformStream<IN, OUT>; /** * Creates a TransformStream from a process's stdio, forwarding stderr to a specified stream * @template IN - Input data type (string or Uint8Array) * @template OUT - Output data type (string or Uint8Array) * @param p - A process object with stdin, stdout, and stderr streams * @param options - Configuration object * @param options.stderr - The writable stream to forward stderr to * @returns A TransformStream that connects stdin to stdout, forwarding stderr separately */ declare function fromStdioAndForwardError<IN extends string | Uint8Array, OUT extends string | Uint8Array>(/** a process, which has stdin, stdout, stderr */ p: { stdin?: Writable | WritableStream | null; stdout?: Readable | ReadableStream | null; stderr?: Readable | ReadableStream | null; }, { stderr }: { stderr: Writable | WritableStream; }): TransformStream<IN, OUT>; /** * Creates a TransformStream from a process's stdio with configurable stderr handling * @template IN - Input data type (string or Uint8Array) * @template OUT - Output data type (string or Uint8Array) * @param p - A process object with stdin, stdout, and stderr streams * @param options - Configuration object for stderr handling * @param options.stderr - Writable stream to forward stderr to, or null to drop stderr, or undefined to merge with stdout * @returns A TransformStream that connects stdin to stdout with the specified stderr behavior */ declare function fromStdio<IN extends string | Uint8Array, OUT extends string | Uint8Array>(/** a process, which has stdin, stdout, stderr */ p: { stdin?: Writable | WritableStream | null; stdout?: Readable | ReadableStream | null; stderr?: Readable | ReadableStream | null; }, { stderr }?: { /** specify stderr to forward, or set to null to drop. */stderr?: Writable | WritableStream | null; }): TransformStream<IN, OUT>; //#endregion export { fromDuplex, fromReadable, fromStdio, fromStdioAndForwardError, fromStdioDropErr, fromStdioMergeError, fromWritable }; //# sourceMappingURL=index.d.mts.map