Last active
July 24, 2018 06:01
-
-
Save simevidas/bd96e7255b59bec55241a4a9d18ac033 to your computer and use it in GitHub Desktop.
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
// pattern 1 | |
await Promise.all( | |
files.map(async file => { | |
let fileSize = await getSize(file); | |
totalSize += fileSize; | |
}) | |
); | |
// pattern 2 | |
let fileSizes = await Promise.all( | |
files.map(async file => getSize(file)) | |
); | |
for (let fileSize of fileSizes) { | |
totalSize += fileSize; | |
} | |
// Too Terse Too Unreadable 1 | |
for (let fileSize of await Promise.all(files.map(getSize))) { | |
totalSize += fileSize; | |
} | |
// Too Terse Too Unreadable 2 | |
totalSize = ( | |
await Promise.all(files.map(getSize)) | |
).reduce((t, s) => t + s, 0); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment