1async function printFiles () {
2 const files = await getFilePaths();
3
4 await Promise.all(files.map(async (file) => {
5 const contents = await fs.readFile(file, 'utf8')
6 console.log(contents)
7 }));
8}
1 for (const file of files) {
2 const contents = await fs.readFile(file, 'utf8');
3 console.log(contents);
4 }
5
1export async function asyncForEach<T>(array: Array<T>, callback: (item: T, index: number) => void) {
2 for (let index = 0; index < array.length; index++) {
3 await callback(array[index], index);
4 }
5 }
6
7await asyncForEach(receipts, async (eachItem) => {
8 await ...
9})
10