2018-07-15 00:41:58 +00:00
|
|
|
function bufferStream(stream) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
const chunks = [];
|
|
|
|
|
|
|
|
stream
|
2018-12-17 17:38:05 +00:00
|
|
|
.on('error', reject)
|
|
|
|
.on('data', chunk => chunks.push(chunk))
|
|
|
|
.on('end', () => resolve(Buffer.concat(chunks)));
|
2018-07-15 00:41:58 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = bufferStream;
|