Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

stream.js 646B

1234567891011121314151617
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.merge = void 0;
  4. const merge2 = require("merge2");
  5. function merge(streams) {
  6. const mergedStream = merge2(streams);
  7. streams.forEach((stream) => {
  8. stream.once('error', (error) => mergedStream.emit('error', error));
  9. });
  10. mergedStream.once('close', () => propagateCloseEventToSources(streams));
  11. mergedStream.once('end', () => propagateCloseEventToSources(streams));
  12. return mergedStream;
  13. }
  14. exports.merge = merge;
  15. function propagateCloseEventToSources(streams) {
  16. streams.forEach((stream) => stream.emit('close'));
  17. }