Skip to content

Instantly share code, notes, and snippets.

@JustinSDK
Created May 7, 2019 06:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JustinSDK/2a6b1c0321d87d77c6e84ed0900a26c4 to your computer and use it in GitHub Desktop.
Save JustinSDK/2a6b1c0321d87d77c6e84ed0900a26c4 to your computer and use it in GitHub Desktop.
es8-for-await.js
// 透過非同步產生器函式
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