Function: readStreamBytes()
readStreamBytes(
stream):Promise<Uint8Array<ArrayBufferLike>>
Drain a readable stream (e.g. process.stdin) into a single byte buffer.
Parameters
stream
Readable
The readable stream to drain.
Returns
Promise<Uint8Array<ArrayBufferLike>>
The concatenated bytes.
Example
import { Readable } from "node:stream";
import { readStreamBytes } from "@cosyte/cli";
const bytes = await readStreamBytes(Readable.from([Buffer.from("MSH|")]));
bytes.length; // => 4