async function* users(from, to) { for (let i = from; i <= to; i++) { const res = await fetch('https://jsonplaceholder.typicode.com/users/' + i); const json = await res.json(); yield json; } } // Map operator for AsyncIterables async function* map(inputAsyncIter, f) { for await (let x of inputAsyncIter) { yield f(x); } } async function main() { const allUsers = users(1, 10); // Pass `allUsers` around, create a new `names` const names = map(allUsers, user => user.name); for await (let name of names) { console.log(name); } } main();
200400cookie-checkJavascript Async Iterable