javascript babel-plugin-transform-async-generator-functions示例
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript babel-plugin-transform-async-generator-functions示例相关的知识,希望对你有一定的参考价值。
{
"name": "async-generator-functions-sample",
"version": "1.0.0",
"description": "async generators / iterators sample with babel",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "babel src -d dist",
"start": "babel-node dist/async.js"
},
"author": "Masashi Hirano (https://github.com/shisama)",
"license": "ISC",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-plugin-transform-async-generator-functions": "^6.24.1",
"babel-preset-env": "^1.6.1"
},
"babel": {
"presets": [
[
"env",
{
"targets": {
"node": 8
},
"excludes": ["transform-regenerator"]
}
]
],
"plugins": [
"transform-async-generator-functions"
]
}
}
async function* foo() {
const promises = [Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)];
for await (const promise of promises) {
yield promise;
}
}
async function bar() {
const f = foo();
while (true) {
const next = await f.next();
if (next.done) {
break;
}
console.log(next.value);
}
}
bar();
以上是关于javascript babel-plugin-transform-async-generator-functions示例的主要内容,如果未能解决你的问题,请参考以下文章
javascript JavaScript isset()等效: - JavaScript
JavaScript 使用JavaScript更改CSS(JavaScript)
JavaScript之基础-1 JavaScript(概述基础语法)
前端基础-JavaScript的基本概述和语法
JavaScript
JavaScript