Baseline Widely available
Symbol.asyncIterator
ì ì ë°ì´í° ìì±ì ì ìë ¤ì§ ì¬ë³¼ Symbol.asyncIterator
를 ëíë
ëë¤. ë¹ë기 ìí íë¡í ì½ì ê°ì²´ì ëí ë¹ë기 ë°ë³µê¸°ë¥¼ ë°ííë ë©ìëì ëí´ ì´ ì¬ë³¼ì ê²ìí©ëë¤. ê°ì²´ê° ë¹ë기 ìíê° ëë ¤ë©´ Symbol.asyncIterator
í¤ê° ìì´ì¼ í©ëë¤.
const delayedResponses = {
delays: [500, 1300, 3500],
wait(delay) {
return new Promise((resolve) => {
setTimeout(resolve, delay);
});
},
async *[Symbol.asyncIterator]() {
for (const delay of this.delays) {
await this.wait(delay);
yield `Delayed response for ${delay} milliseconds`;
}
},
};
(async () => {
for await (const response of delayedResponses) {
console.log(response);
}
})();
// Expected output: "Delayed response for 500 milliseconds"
// Expected output: "Delayed response for 1300 milliseconds"
// Expected output: "Delayed response for 3500 milliseconds"
ê°
ì ìë ¤ì§ ì¬ë³¼ Symbol.asyncIterator
.
ê°ì²´ì [Symbol.asyncIterator]
ìì±ì ì¤ì íì¬ ìì ë§ì ë¹ë기 ìí를 ì ìí ì ììµëë¤.
const myAsyncIterable = {
async *[Symbol.asyncIterator]() {
yield "hello";
yield "async";
yield "iteration!";
},
};
(async () => {
for await (const x of myAsyncIterable) {
console.log(x);
}
})();
// Logs:
// "hello"
// "async"
// "iteration!"
API를 ë§ë¤ ë ë¹ë기 ìíë ëë¶ë¶ì ìí©ìì ì½ë°±ì´ë ì´ë²¤í¸ë¥¼ ìì í ëì²´íë ê²ì´ ìëë¼ ë°ì´í° ì¤í¸ë¦¼ì´ë 목ë¡ê³¼ ê°ì´ ìí를 íííëë¡ ì¤ê³ëììì 기ìµíì기 ë°ëëë¤.
ë´ì¥ ë¹ë기 ìííµì¬ JavaScript ì¸ì´ìë ë¹ë기 ìí ê°ë¥í ê°ì²´ê° ììµëë¤. ReadableStream
ì ê°ì ì¼ë¶ ì¹ APIìë 기본ì ì¼ë¡ Symbol.asyncIterator
ë©ìëê° ì¤ì ëì´ ììµëë¤.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4