Skip to content

Instantly share code, notes, and snippets.

@marcaosi
Created July 19, 2017 12:55
Show Gist options
  • Save marcaosi/f5d104a7caf4f6633c5621ec4fd3568c to your computer and use it in GitHub Desktop.
Save marcaosi/f5d104a7caf4f6633c5621ec4fd3568c to your computer and use it in GitHub Desktop.
const fs = require('fs')
function readdirPromise(path){
return new Promise((resolve, reject) => {
fs.readdir(path, (err, files) => {
if(err){
reject(err)
}else{
resolve(files)
}
})
})
}
// readdirPromise('./').then((files)=> console.log(files))
async function lerArquivos(path){
const arquivos = await readdirPromise('./');
console.log(arquivos);
}
lerArquivos()
@tuliofaria
Copy link

Certinho.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment