stream-to-promise.js 446 B

123456789101112
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.streamToPromise = void 0;
  4. function streamToPromise(stream) {
  5. const data = [];
  6. return new Promise((resolve, reject) => stream
  7. .on('data', (chunk) => data.push(chunk.toString('utf-8')))
  8. .on('error', reject)
  9. .on('end', () => resolve(data)));
  10. }
  11. exports.streamToPromise = streamToPromise;
  12. //# sourceMappingURL=stream-to-promise.js.map