-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy patha-iterator.js
More file actions
29 lines (26 loc) · 488 Bytes
/
Copy patha-iterator.js
File metadata and controls
29 lines (26 loc) · 488 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';
const range = {
start: 1,
end: 10,
[Symbol.asyncIterator]() {
let value = this.start;
return {
next: () =>
new Promise((resolve) => {
setTimeout(() => {
resolve({
value,
done: value++ === this.end + 1,
});
}, 0);
}),
};
},
};
const main = async () => {
console.dir({ range });
for await (const number of range) {
console.log(number);
}
};
main();