blob: 0155f088a22159d32ca77d486b872a1c8e415e65 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
"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;
|