Created
May 7, 2019 06:21
-
-
Save JustinSDK/2a6b1c0321d87d77c6e84ed0900a26c4 to your computer and use it in GitHub Desktop.
es8-for-await.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 透過非同步產生器函式 | |
const vertex2 = { | |
x: 1, | |
y: 2, | |
z: 3, | |
[Symbol.asyncIterator]: async function* () { | |
for (let key in this) { | |
yield this[key]; | |
} | |
} | |
}; | |
(async function () { | |
for await (const x of vertex2) { | |
console.log(x); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment