TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Let’s get serious about ES6 generator functions

112 pointsby jamesgpearceover 11 years ago

6 comments

eldudeover 11 years ago
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 未加载
bnjmnover 11 years ago
Primary author here. Ask me anything!
评论 #6594701 未加载
评论 #6594730 未加载
评论 #6595721 未加载
评论 #6595026 未加载
评论 #6595343 未加载
评论 #6594828 未加载
评论 #6595231 未加载
评论 #6594713 未加载
评论 #6596063 未加载
评论 #6596355 未加载
评论 #6594682 未加载
评论 #6595913 未加载
shtylmanover 11 years ago
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 未加载
jessepover 11 years ago
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 未加载
zamalekover 11 years ago
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>
pornelover 11 years ago
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 未加载