Investigate why the following code won't run
let promises = [
Promise.resolve(1),
Promise.reject('dada'),
Promise.resolve(3)
]
(async () => {
try {
let results = await Promise.all(promises);
console.log(results.join(','))
}
catch(ex) {
console.log(ex)
}
})()
async function* fetch() {
let page = 1, lastPage = 5;
while(page < lastPage)
yield await Promise.resolve(page++) // async http request maybe?
}
(async () => {
for await(let page of fetch()) {
console.log('page ' + page)
}
})()
let promises = [
Promise.resolve(1),
Promise.reject('dada'),
Promise.resolve(3)
]
(async () => {
try {
let results = await Promise.all(promises);
console.log(results.join(','))
} catch(ex) { // `catch` need following the right brace `}`
console.log(ex) // output: 'dada'
}
})()
great, thank you @plylrnsdy. Guess I'm not into javascript anymore, it's allowed in typescript :-)
the last one with the async generator may be that it isn't supported in Node 8.9? Or I'm missing how to augment asyncIterator to Symbol.
for await isn't supported in 8.9 - either rewrite with helpers or parse through ts-node
https://jakearchibald.com/2017/async-iterators-and-generators/ https://medium.com/@segersian/howto-async-generators-in-nodejs-c7f0851f9c02
I think the extension can use child process to create a new Node process as REPL with user's Node.js, so that we can use Node.js which the version user had.