Asynchronous map function that await's returns Promise instead of value
try
async function addFiles(dir,tree) {
const files = await readDir(dir)
await Promise.all(files.map(async (name) => {await readDir(dir); return name;})
}
If you're using bluebird you can use this cleaner, shorter syntax with Promise.map
async function addFiles(dir, tree) {
const files = await readDir(dir);
return Promise.map(files, async (name) => { await readDir(dir); return name; });
}