Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to not nest your callbacks.
var fs = require('fs'),
total = '';
function readAndConcat(files) {
files.forEach(gotFile);
}
function gotFile(file) {
fs.readFile(file, useData);
}
function useData(err, data) {
if (err) { return; }
total += data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.