News for hackers. Stuff that matters.
Re:Node 5.7.0 (stable) released by alfonsodev on Friday February 26, 2016 @06:22AM (#11180866)
I started to use async/await because react-native and now I can't live without it. In nodejs you can have it:

npm install --save babel-core babel-loader babel-polyfill babel-preset-es2015 babel-preset-stage-0

Adding this to entry point file

  require("babel-core/register");
  require("babel-polyfill");
and having a .babelrc with these presets:

  {
    "presets": ["es2015", "stage-0"]
  }
Then you can transpile with babel-cli ( sudo npm install -g babel-cli if you don't have it yet)

  babel app.js -o transpiled_app.js
Make sure you have npm version 3, or it become too slow to initialise.

as @vdaniuk mention Chackra supports it, but did anyone tried this https://github.com/nodejs/node-chakracore?

Is there any other way to get async/await today ?

Re:Node 5.7.0 (stable) released by davej on Friday February 26, 2016 @11:29AM (#11182238)
Worth considering the es2015-node5 preset instead. It will only transpile the features that are not already in node 5.x. The standard es2015 preset transpiles lots of APIs that are already natively available in node 5.
Re:Node 5.7.0 (stable) released by esailija on Friday February 26, 2016 @06:47AM (#11180931)
coroutines with generators are more powerful (cancellation, automatic resource cleanup when the generator terminates etc) and have worked for a long time out of the box. The only difference is that you write `yield` instead of `await` and `decorator(function*` instead of `async function`
Re:Node 5.7.0 (stable) released by phpnode on Friday February 26, 2016 @07:42AM (#11181061)
Babel can transform async functions into Bluebird coroutines, so the best of both worlds - https://www.npmjs.com/package/babel-plugin-transform-async-t...
Re:Node 5.7.0 (stable) released by esailija on Friday February 26, 2016 @07:51AM (#11181089)
Yes but with this you lose the powerful features I just mentioned: automatic resource cleanup[1], cancellation, yield handlers.. don't you?

1. https://github.com/petkaantonov/bluebird/issues/1014

Re:Node 5.7.0 (stable) released by phpnode on Friday February 26, 2016 @09:17AM (#11181444)
No I think those should work with async functions as it is literally just translating `async` -> `yield`, but worth investigating.
Re:Node 5.7.0 (stable) released by alfonsodev on Friday February 26, 2016 @08:16AM (#11181173)
Thanks for commenting on that, I didn't think about those issues. I'll research on how much impact could have on performance. In the other hand I believe syntax is not the only difference. I'm not full time js dev, but after a quick search, I found Domenic pointing 4 differences here https://esdiscuss.org/topic/does-async-await-solve-a-real-pr...
Re:Node 5.7.0 (stable) released by esailija on Friday February 26, 2016 @08:55AM (#11181335)
These seem to be mostly about undecorated generators. 3. Is a legit difference but it is actually a syntax error to do yield 1 + yield 2. So that is fixable in a backward compatible way.
Re:Node 5.7.0 (stable) released by mtzaldo on Friday February 26, 2016 @08:17AM (#11181176)
Could you put a reference for the decorator/yield usage? Thanks
Re:Node 5.7.0 (stable) released by esailija on Friday February 26, 2016 @08:45AM (#11181295)
Re:Node 5.7.0 (stable) released by mtzaldo on Friday February 26, 2016 @09:51AM (#11181631)
Thanks, I will review it.
Re:Node 5.7.0 (stable) released by l1ambda on Friday February 26, 2016 @11:21AM (#11182192)
https://github.com/llambda/koa-boiler/blob/master/app.js#L75 is an example of Bluebird coroutines paired with Koa.