4 ms·
I much rather write coffeescript, but at least I can understand the code much better this way and it is not such an abomination. await getUsers(), defer er
by romanovcode 10y ago
I much rather write coffeescript, but at least I can understand the code much better this way and it is not such an abomination.
await getUsers(), defer err, users
return cb err if err?
await filterUsersWithFriends users, defer err, users
return cb err, users
I seriously don't get how people like Javascript when to do such a simple things you need so much code that looks so ugly (IMO).
- doublerebel 10y agoThis is how I've been writing Iced Coffeescript for years. I still believe it's a major improvement over the typical promise syntax. And to make the error handling even cleaner, check out the errify/errorCallback pattern: http://maxtaco.github.io/programming/2014/09/18/handling-errors-in-iced-coffee-script/ http://maxtaco.github.io/programming/2014/09/18/handling-err... https://www.npmjs.com/package/errify https://www.npmjs.com/package/errify https://github.com/nextorigin/express-rendertype/blob/master/src/fancy.coffee https://github.com/nextorigin/express-rendertype/blob/master...
- romanovcode 10y agoHm, looks interesting. I wonder if it would be possible to monkey-patch the defer itself in something like this. So that defer itself is handling it, but only if you do the the monkey-patching per file and not globally. defer = require 'defer-esc' await req.get 'https://x.io', defer err, http, res # if err will call cb err await req.get "https://x.io?hash=#{res.hash}", defer err, http, res # if err will call cb err return cb res