Skip to content

Commit cb22073

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

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: JavaScript/6-promise.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ 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) onSuccess(res);
4748
if (onDone) onDone(err, res);
4849
if (this.count === 0 && this.waiting.length === 0 && onDrain) onDrain();
4950
}

0 commit comments

Comments
 (0)