Skip to content

Instantly share code, notes, and snippets.

@helton
Created July 20, 2017 02:46
Show Gist options
  • Save helton/388cd56f4ec6907e5034e6dc97dd0e32 to your computer and use it in GitHub Desktop.
Save helton/388cd56f4ec6907e5034e6dc97dd0e32 to your computer and use it in GitHub Desktop.
Full Stack Academy - Aula 01 - Exercicio 04
/*
* [Exercício 4]
*
* Construa uma função async que utiliza a função readdirPromise com await e
* escreva no console a lista de arquivos/diretórios retornados.
*/
const fs = require('fs')
const readdirPromise = (path) => new Promise((resolve, reject) =>
fs.readdir(path, (err, files) =>
err ? reject(err) : resolve(files)
)
)
const readdirAsync = async (path) => {
const files = await readdirPromise(path)
console.log(files);
}
readdirAsync('./')
@tuliofaria
Copy link

Certinho.

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