Sorry, should have clarified on 2. As an expansion of one of the examples given:
loadAndPrintFile: (contents) {
if (!contents) {
fs.readFile() -> (error!, contents)
}
console.log(contents);
}
i.e., expected behavior would be as if readFile was not an async function.I'm asking because I built something similar (though it only worked with promises, not general async functions), and I'm curious to compare approaches :-) - mine is a sweet.js macro: http://pastie.org/9410315 (uses https://github.com/petkaantonov/bluebird and https://github.com/BranchMetrics/promise-accum). The basic syntax would be:
task {
item1 <- LoadItem(1);
item2 <- LoadItem(item1.foreign_key);
ret <- DoSomethingWithItems(item1, item2);
}