Skip to content

Commit d16e80d

Browse files
committed
Fix finish method
1 parent 91630c0 commit d16e80d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

JavaScript/6-promise.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ class Queue {
4242

4343
finish(err, res) {
4444
const { onFailure, onSuccess, onDone, onDrain } = this;
45-
if (err && onFailure) onFailure(err, res);
46-
else if (onSuccess) onSuccess(res);
45+
if (err) {
46+
if (onFailure) onFailure(err, res);
47+
} else if (onSuccess) {
48+
onSuccess(res);
49+
}
4750
if (onDone) onDone(err, res);
4851
if (this.count === 0 && this.waiting.length === 0 && onDrain) onDrain();
4952
}

0 commit comments

Comments
 (0)