You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
646 B

2 years ago
  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. }