/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { createReadStream } from "node:fs"; import { readFile } from "node:fs/promises"; import { Readable } from "node:stream"; export function filesToStream(filePath: string): ReadableStream { return Readable.toWeb( createReadStream(filePath), ) as ReadableStream; } export async function filesToByteArray(filePath: string): Promise { return readFile(filePath); } export async function filesToString(filePath: string): Promise { return readFile(filePath, "utf8"); } export async function streamToByteArray( stream?: ReadableStream, ): Promise { if (!stream) { return Buffer.from(""); } const chunks = []; const reader = stream.getReader(); let done = false; while (!done) { const res = await reader.read(); done = res.done; if (res.value) { chunks.push(res.value); } } return Buffer.concat(chunks); }