get iterator result in for...of syntax

for of syntax is useful to iterate over an iterator. But there is no way to access the return value for an iterator.

function *myWork() {
    let x = 0
    while (x < 10) yield (x++)/10
    // the yielded number is work progress
    return 'work result'
}

But for this kind of iterator, we can't use the for of syntax to iterate over the iterator because it will ignore the result

for (const x of myWork()) console.log(x)
// "work result" is dropped

I have to iterate this kind of iterator by hand, it's not so good.

If we can make for of and for await of syntax to become expression, we can get the result now.

const result = for await (const progress of download()) {
    ui.updateProgress(progress)
}