Skip to content

Instantly share code, notes, and snippets.

@thebergamo
Last active August 29, 2015 14:02
Show Gist options
  • Save thebergamo/58bb7d9336946150474e to your computer and use it in GitHub Desktop.
Save thebergamo/58bb7d9336946150474e to your computer and use it in GitHub Desktop.
recursividade.js
files = ['a.txt', 'j.txt'];
ret = "";
function concatFiles(file, ret){
shifted = file.shift();
if(!shifted){
console.log(ret);
return;
}
fs = require('fs');
fs.readFile(shifted, 'utf8', function (err,data) {
if (err) {
return console.log(err);
}
ret += data.toString();
concatFiles(file, ret);
});
}
concatFiles(files, ret);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment