From ce2bb55b2430ec732a13a9fbca136b26db564ea3 Mon Sep 17 00:00:00 2001 From: Jerry Kurian Date: Mon, 27 Jan 2020 16:10:00 -0500 Subject: [PATCH] Emit correct event --- src/functions/demux.ts | 9 +++++---- tests/demux.spec.ts | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/functions/demux.ts b/src/functions/demux.ts index 963b6c3..35b3a1f 100644 --- a/src/functions/demux.ts +++ b/src/functions/demux.ts @@ -1,4 +1,4 @@ -import { DuplexOptions, Duplex, Transform } from "stream"; +import { DuplexOptions, Duplex, Transform, Writable } from "stream"; import { isReadable } from "../helpers"; @@ -48,10 +48,11 @@ class Demux extends Duplex { ...options, transform: (d, _, cb) => { this.push(d); - cb(null, d); + cb(null); }, }); - this.once("unpipe", () => this._flush()); + + this.on("unpipe", () => this._flush()); } public _read(size: number) {} @@ -87,7 +88,7 @@ class Demux extends Duplex { totalEnded++; if (pipelines.length === totalEnded) { this.push(null); - this.emit("finished"); + this.emit("end"); } }); }); diff --git a/tests/demux.spec.ts b/tests/demux.spec.ts index 3e1dae0..93be081 100644 --- a/tests/demux.spec.ts +++ b/tests/demux.spec.ts @@ -724,7 +724,7 @@ test.cb("Demux should send data events", t => { }); }); -test.cb("demux() `finish` and `end` propagates", t => { +test.cb.only("demux() `finish` and `end` propagates", t => { interface Chunk { key: string; mapped: number[];