Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify AsyncIterable docs #168

Open
joebowbeer opened this issue Nov 12, 2024 · 0 comments
Open

Clarify AsyncIterable docs #168

joebowbeer opened this issue Nov 12, 2024 · 0 comments

Comments

@joebowbeer
Copy link

Two questions about "extracting as an async iterator"

https://github.com/mafintosh/tar-stream?tab=readme-ov-file#extracting-as-an-async-iterator

The extraction stream in addition to being a writable stream is also an async iterator

  1. Is it an AsyncIterable or an AsyncIterator?

  2. How are the bodies of the entries consumed?

Is the following correct? (I think this works for me.)

for await (const entry of extract) {
  if (entry.header.type === "file") {
    for await (const chunk of entry) {
      process(chunk);
    }
  } else {
    entry.resume();
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant