Created
July 20, 2017 02:46
-
-
Save helton/388cd56f4ec6907e5034e6dc97dd0e32 to your computer and use it in GitHub Desktop.
Full Stack Academy - Aula 01 - Exercicio 04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* [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('./') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Certinho.