Skip to content

Commit 83f77bb

Browse files
committed
Fix the incorrect task.next()
1 parent a9d7b19 commit 83f77bb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

manuscript/10-Promises.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -771,19 +771,19 @@ function run(taskDef) {
771771
// create the iterator
772772
let task = taskDef();
773773

774+
// start the task
775+
let result = task.next();
776+
774777
// recursive function to iterate through
775778
(function step() {
776779

777-
let result = task.next(),
778-
promise;
779-
780780
// if there's more to do
781781
if (!result.done) {
782782

783783
// resolve to a promise to make it easy
784-
promise = Promise.resolve(result.value);
784+
let promise = Promise.resolve(result.value);
785785
promise.then(function(value) {
786-
task.next(value);
786+
result = task.next(value);
787787
step();
788788
}).catch(function(error) {
789789
task.throw(error);

0 commit comments

Comments
 (0)