Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fixed onDrain call when queue is drained
  • Loading branch information
dmytro-doroshenko committed Apr 2, 2024
commit aa09cfe26490ee567e70557ddd963c6a5b540739
2 changes: 1 addition & 1 deletion JavaScript/6-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class Queue {
(err) => void this.finish(err)
)
.finally(() => {
this.count--;
if (this.waiting.length > 0) this.next();
});
}
Expand All @@ -45,6 +44,7 @@ class Queue {
if (err && onFailure) onFailure(err, res);
else if (onSuccess) onSuccess(res);
if (onDone) onDone(err, res);
this.count--;
if (this.count === 0 && this.waiting.length === 0 && onDrain) onDrain();
}

Expand Down