News for hackers. Stuff that matters.

throwasfwa331

Re:TypeScript 5.2's New Keyword: 'using' on Tuesday June 20, 2023 @11:13AM (#36405182)
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);