|
|
|
|
|
by Cushman
4228 days ago
|
|
Another reason to prefer CoffeeScript is because of its low cost of both defining and calling functions. The combination makes functional programming, including working with callbacks and promises, much less of a headache. Even if you don't know CS very well, I dare you to take a look at the JavaScript this compiles to and call it more readable: (req, res)->
getUserIds(req.query)
.then (ids)->
Promise.all ids.map (id)->
getUser(id).then (user)-> user.friends.count
.then (response)-> res.send 200, response
.catch (error)-> res.send 500, error
|
|
You code compiles to:
Not what intended, I assume :)