Ashley Coolman Ashley Coolman - 1 year ago 82
Node.js Question

Can I use ES6's arrow function syntax with generators? (arrow notation)

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 Source

You can't. Sorry.

According to MDN

The function* statement (function keyword followed by an asterisk) defines a generator function.

From a spec document:

The function syntax is extended to add an optional * token:

FunctionDeclaration: "function" "*"? Identifier "(" FormalParameterList? ")" "{" FunctionBody "}"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download