TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Let’s get serious about ES6 generator functions

112 点作者 jamesgpearce超过 11 年前

6 条评论

eldude超过 11 年前
Good stuff. This will come in handy if node.js 0.12 takes much longer.<p>Watching the use of generators in JavaScript and especially node.js is going to be very exciting over the coming years. We&#x27;re excited at LinkedIn because we write a lot of node.js, and control flow is always being discussed: step, async, stepup, promises, and async generators look to solve a lot of that.<p>Also, checkout the AGen formal spec[1] for asynchronous generators. Raynos and I put it together recently to encourage interoperability between async generator solutions, and we&#x27;re both using it in personal projects.[2]<p>[1] <a href="https://github.com/AsynchronousGenerators/agen-spec" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;AsynchronousGenerators&#x2F;agen-spec</a><p>[2] <a href="https://github.com/Raynos/gens" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Raynos&#x2F;gens</a>
评论 #6595981 未加载
bnjmn超过 11 年前
Primary author here. Ask me anything!
评论 #6594701 未加载
评论 #6594730 未加载
评论 #6595721 未加载
评论 #6595026 未加载
评论 #6595343 未加载
评论 #6594828 未加载
评论 #6595231 未加载
评论 #6594713 未加载
评论 #6596063 未加载
评论 #6596355 未加载
评论 #6594682 未加载
评论 #6595913 未加载
shtylman超过 11 年前
You should make a browserify transform (<a href="https://github.com/substack/node-browserify" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;substack&#x2F;node-browserify</a>) so that it can easily be put into a pipeline to convert generator code to es5 code. Folks using browserify will be able to use it very easily.
评论 #6594765 未加载
jessep超过 11 年前
Thank you! This is so exciting. I&#x27;ve been wanting to try things like go style concurrency (<a href="http://swannodette.github.io/2013/08/24/es6-generators-and-csp/" rel="nofollow">http:&#x2F;&#x2F;swannodette.github.io&#x2F;2013&#x2F;08&#x2F;24&#x2F;es6-generators-and-c...</a>) in the browser, and this seems like it will help us get there. Granted, haven&#x27;t tried it yet, and really understand nothing about any of this, but ... Anyway, hooray :)
评论 #6596525 未加载
zamalek超过 11 年前
This is similar to my asyncscript pet project[1] (that was met with much resistance on the Node.js mailing list as it was Yet Another CPS Framework). It drew inspiration from the way that C# creates the state machines for &quot;yield&quot; and &quot;await&quot;. The project is dead (it only dealt with async calls and I never got round to &quot;enumeration generators&quot;), but if you are wondering how regenerator works I have a nice explanation at the bottom of readme.md.<p>[1]: <a href="https://github.com/jcdickinson/asyncscript" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jcdickinson&#x2F;asyncscript</a>
pornel超过 11 年前
I couldn&#x27;t find information why generator functions in JS require &#x27;*&#x27; in the syntax (ES6 spec&#x2F;wiki just states this as a fact, but no rationale). Does anybody know?<p>Python manages to work fine without ugly wart in the syntax, and it seems to me that presence of `yield` keyword in body is enough at syntactical level to tell compiler that the function is a generator.
评论 #6598173 未加载