17 lines
498 B
Plaintext
17 lines
498 B
Plaintext
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
// TODO: Update https://github.com/sindresorhus/get-stream
|
|
const getBuffer = async (stream) => {
|
|
const chunks = [];
|
|
let length = 0;
|
|
for await (const chunk of stream) {
|
|
chunks.push(chunk);
|
|
length += Buffer.byteLength(chunk);
|
|
}
|
|
if (Buffer.isBuffer(chunks[0])) {
|
|
return Buffer.concat(chunks, length);
|
|
}
|
|
return Buffer.from(chunks.join(''));
|
|
};
|
|
exports.default = getBuffer;
|