mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 07:53:06 +01:00
527e2147af
PR-URL: https://github.com/nodejs/node/pull/33991 Fixes: https://github.com/nodejs/node/issues/33582 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com>
40 lines
654 B
JavaScript
40 lines
654 B
JavaScript
'use strict';
|
|
|
|
const {
|
|
Promise,
|
|
} = primordials;
|
|
|
|
let pl;
|
|
let eos;
|
|
|
|
function pipeline(...streams) {
|
|
if (!pl) pl = require('internal/streams/pipeline');
|
|
return new Promise((resolve, reject) => {
|
|
pl(...streams, (err, value) => {
|
|
if (err) {
|
|
reject(err);
|
|
} else {
|
|
resolve(value);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
function finished(stream, opts) {
|
|
if (!eos) eos = require('internal/streams/end-of-stream');
|
|
return new Promise((resolve, reject) => {
|
|
eos(stream, opts, (err) => {
|
|
if (err) {
|
|
reject(err);
|
|
} else {
|
|
resolve();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
module.exports = {
|
|
finished,
|
|
pipeline,
|
|
};
|