JavaScript Declare anonymous generator function using arrow syntax [duplicate]

ie how do I express this:

function *(next) {}

with arrows. I've tried all the combinations I could think of, and I can't find any documentation on it.

(currently using node v0.11.14)

Answer:1

In addition to the discussion on esdiscuss.org and the Ecma TC39 committee ES6 meeting notes from November 2013 mentioned above, generator arrows were revisited in two September 2016 ES7 meetings [1] [2]. After a discussion about pros and cons of various syntax (mainly =*> and =>*) and a lack of justifications and use cases for this feature, they came to the conclusion that:

  • There is some interest from the committee, but concern that the feature does not pull its weight for adding a new piece of syntax
  • Plan to revisit on Day 3 to see if we can get =>* to stage 0 at least, as part of [Domenic Denicola]'s async iteration proposal

The proposal for generator arrows was moved to Stage 1 with Brendan Eich and Domenic Denicola as champions. Asynchronous iteration mentioned above was finished and implemented in 2018.

In Oct 2019 an official repo by Sergey Rubanov appeared with more discussion about syntax and other details.

Answer:2

I know that this is very late, but another possible reason could be syntax. maybe (*() => {}) works, but what about (9 ** () => {})? Is that 9 to the power of an arrow function, returning NaN, or is it 9 times a generator arrow function, also returning NaN? It could be done with some alternative syntax, like =>* as mentioned by another answer here, but maybe there was a desire to preserve the consistency of the generator function syntax (eg. function* () {} and { *genMethod() {} }) when it was being implemented. Not too much of an excuse, but a reason for it.

Answer:3

Right now you can not, but in future you might be because TC39 release proposal for same in october 2019, which is in stage 1.

Answer:4

Title - Sorry about the title, it was difficult for me to actually explain this. So I recently finished working on a dynamic fields system using jQuery. This is all working great however I'm wanting ...

Title - Sorry about the title, it was difficult for me to actually explain this. So I recently finished working on a dynamic fields system using jQuery. This is all working great however I'm wanting ...

I was wondering if there was a feature or a way to select on line at a time from jquery/javascript. The issues is that it must be the element inside a <pre></pre> tags. The code look like ...

I was wondering if there was a feature or a way to select on line at a time from jquery/javascript. The issues is that it must be the element inside a <pre></pre> tags. The code look like ...

I Have four grids in Dojo, all of which update with real time data every few seconds. I only display one grid to the user at a time, but in the background all four grids update. This makes the page ...

I Have four grids in Dojo, all of which update with real time data every few seconds. I only display one grid to the user at a time, but in the background all four grids update. This makes the page ...

I am trying to dynamically create a simple select which contains an object's property as the option based on some constraints. Everything works fine when my JSON is a part of the script. FIDDLE The ...

I am trying to dynamically create a simple select which contains an object's property as the option based on some constraints. Everything works fine when my JSON is a part of the script. FIDDLE The ...