UNPKG

ravendb

Version:
38 lines 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.pipelineAsync = exports.finishedAsync = void 0; exports.readToBuffer = readToBuffer; exports.readToEnd = readToEnd; exports.bufferToReadable = bufferToReadable; exports.stringToReadable = stringToReadable; const node_stream_1 = require("node:stream"); const node_util_1 = require("node:util"); const node_buffer_1 = require("node:buffer"); exports.finishedAsync = (0, node_util_1.promisify)(node_stream_1.finished); exports.pipelineAsync = (0, node_util_1.promisify)(node_stream_1.pipeline); async function readToBuffer(stream) { const chunks = []; stream .on("data", data => chunks.push(data)); await (0, exports.finishedAsync)(stream); return node_buffer_1.Buffer.concat(chunks); } async function readToEnd(readable) { const chunks = []; readable.on("data", chunk => chunks.push(chunk)); await (0, exports.finishedAsync)(readable); return node_buffer_1.Buffer.concat(chunks).toString("utf8"); } function bufferToReadable(b) { const result = new node_stream_1.Readable(); result.push(b); result.push(null); return result; } function stringToReadable(s) { const result = new node_stream_1.Readable(); result.push(s); result.push(null); return result; } //# sourceMappingURL=StreamUtil.js.map