RethinkDB with io.js: exploring ES6 generators and the future of JavaScript (rethinkdb.com) 67 points by mglukhovsky 11y ago ↗ HN
[–] sandstrom 11y ago ↗ I like the article, and I look forward to ES6 generators.However, if someone want the compactness of the second example today, CoffeeScript is another alternative: conn = undefined r.connect().then (c) -> conn = c r.dbCreate('quake').run(conn) .then -> r.db('quake').tableCreate('quakes').run(conn) .then -> r.db('quake').table('quakes') .indexCreate('geometry', geo: true).run(conn) .then -> r.db('quake').table('quakes') .insert(r.http(feedUrl)('features')).run(conn) .error (err) -> console.log(err) if err.msg.indexOf('already exists') == -1 .finally -> conn.close() if conn (obviously the main benefits with generators aren't concise code, but since the article mentioned conciseness I thought I'd post the CoffeeScript equivalent) [–] espadrine 11y ago ↗ JS' fat arrow is also coming, which would give a similarly succinct code. [–] Bahamut 11y ago ↗ That can be done via ES6 as well, replacing -> with => and adding parentheses for those lambdas. [–] sandstrom 11y ago ↗ True! The only difference are implicit returns and significant whitespace I guess (and trailing same-line conditionals).(think it'll even have the skinny arrow, the fat one binds `this` too)
[–] Bahamut 11y ago ↗ That can be done via ES6 as well, replacing -> with => and adding parentheses for those lambdas. [–] sandstrom 11y ago ↗ True! The only difference are implicit returns and significant whitespace I guess (and trailing same-line conditionals).(think it'll even have the skinny arrow, the fat one binds `this` too)
[–] sandstrom 11y ago ↗ True! The only difference are implicit returns and significant whitespace I guess (and trailing same-line conditionals).(think it'll even have the skinny arrow, the fat one binds `this` too)
4 comments
[ 3.1 ms ] story [ 21.3 ms ] threadHowever, if someone want the compactness of the second example today, CoffeeScript is another alternative:
(obviously the main benefits with generators aren't concise code, but since the article mentioned conciseness I thought I'd post the CoffeeScript equivalent)(think it'll even have the skinny arrow, the fat one binds `this` too)