I know that asynchronicity is half the point of node.js and that it’s really great and efficient. However in some situations this programming pattern is just overkill and difficult. For instance, what if you wanted to write a script that takes some user input and uses it to create a MySQL row and saves it (I’ve just done this). It’s really annoying to have to create a separate function for every tiny step of the program and then have them all call each other in a row.
So how should such situations instead be handled? I tried out step, but it won’t work with coffee-script since it requires functions to be declared in the classic manner (function foo() {/* Bar */}). Coffee-script instead creates anonymous functions and assigns them to local variables (var foo = function() {/* Bar */})
I’m thinking it would just be simpler to mix up a method to get the process to wait for a callback to run. Arguments for asynchronicity aside, how would I go about doing this?
Try https://github.com/caolan/async
The list of “Most Depended On” packages on http://search.npmjs.org/ provides insights into how acclaimed libraries are within the node community. async is in 7th place (depended on by 207 packages)…
Avoid libraries that “do not work” with CoffeeScript; they are trouble.