|
|
|
|
|
by zbanks
5468 days ago
|
|
It's still nesting callbacks, just not inline. Also, for the second example, this might be a cleaner solution: var fs = require('fs');
function writeFile(filename){
return function(err){
if (err) throw err;
console.log('Wrote ' + filename);
}
}
function writeHello(){
return fs.writeFile('./hello.txt', 'Hello!', writeFile("hello.txt"));
}
function writeWorld(){
return fs.writeFile('./world.txt', 'World!', writeFile("world.txt"));
}
writeHello();
writeWorld();
|
|