Skip to content

Commit

Permalink
fix: emit the end event
Browse files Browse the repository at this point in the history
  • Loading branch information
wkillerud committed Jul 17, 2024
1 parent 6f2225c commit 6d9c06c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/podlet-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ export class PodletStream extends EventEmitter {
let assets = new Map();
/** @type {Map<string, string[]>} */
let contents = new Map();
/** @type {Map<string, boolean>} */
let done = new Map();

let didEmitBeforeStream = false;
/** @type {string[]} */
let queue = [];
let done = 0;

for (let podlet of podlets) {
podlet
Expand Down Expand Up @@ -101,12 +100,14 @@ export class PodletStream extends EventEmitter {
do {
let toEmit = queue.pop();
this.emit('data', toEmit);
done += 1;
} while (queue.length !== 0);
}

this.emit('data', toEmit);
done += 1;

if (done.size === podlets.length) {
if (done === podlets.length) {
this.emit('end');
}
});
Expand Down

0 comments on commit 6d9c06c

Please sign in to comment.