What would the code look like for my example using futures in JavaScript?
fs.readFile("person.json")
.then(function(e, personJson) {
var person = JSON.parse(personJson);
return myDB.query("lastname", person.name);
})
.then(function(matched) {
return msgQueue.push(JSON.stringify(matchesLastname));
})
.then(function(id) {
log.info("Message sent to queue: " + id);
}); var readFile = Q.denodeify(FS.readFile);
which doesn't create the promise. it just wraps the readFile method so that it returns a promise when you call it.