in Older/ReSharper20172TypeScript/Async.js [15:42]
function asyncIteratorExample() {
return __awaiter(this, void 0, void 0, function* () {
const fetchPromises = [
fetch('file1.txt'),
fetch('file2.txt'),
fetch('file3.txt')
];
// Regular iterator
for (const item of fetchPromises) {
console.log(item); // Will log a promise
}
try {
// Async iterator
for (var fetchPromises_1 = __asyncValues(fetchPromises), fetchPromises_1_1; fetchPromises_1_1 = yield fetchPromises_1.next(), !fetchPromises_1_1.done;) {
const item = yield fetchPromises_1_1.value;
console.log(item); // Will log a response
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (fetchPromises_1_1 && !fetchPromises_1_1.done && (_a = fetchPromises_1.return)) yield _a.call(fetchPromises_1);
}
finally { if (e_1) throw e_1.error; }
}
var e_1, _a;
});
}