Skip to content

Clarify AsyncIterable docs #168

@joebowbeer

Description

@joebowbeer

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();
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions