Better HN
topnewbestaskshowjobs
Log inSign up

throwasfwa331

1 karma · joined Jun 20, 2023 (3y ago) · 1 submissions

Submissions

comment 3y ago · link · parent

Your example is incorrect.

  let totalSize = 0;
  const fileListHandle = await open("file-list.txt", "r");
  try {
    for await (const line of fileListHandle.readLines()) {
      const lineFileHandle = await open(lineFileHandle, "r");
      try {
        totalSize += await lineFileHandle.read().bytesRead;
      } finally {
        await lineFileHandle.close();
      }
    }
  } finally {
    await fileListHandle.close();
  }
  console.log(totalSize);