ravendb
Version:
RavenDB client for Node.js
31 lines • 954 B
JavaScript
import { finished, pipeline, Readable } from "node:stream";
import { promisify } from "node:util";
import { Buffer } from "node:buffer";
export const finishedAsync = promisify(finished);
export const pipelineAsync = promisify(pipeline);
export async function readToBuffer(stream) {
const chunks = [];
stream
.on("data", data => chunks.push(data));
await finishedAsync(stream);
return Buffer.concat(chunks);
}
export async function readToEnd(readable) {
const chunks = [];
readable.on("data", chunk => chunks.push(chunk));
await finishedAsync(readable);
return Buffer.concat(chunks).toString("utf8");
}
export function bufferToReadable(b) {
const result = new Readable();
result.push(b);
result.push(null);
return result;
}
export function stringToReadable(s) {
const result = new Readable();
result.push(s);
result.push(null);
return result;
}
//# sourceMappingURL=StreamUtil.js.map