UNPKG

@obsidize/tar-browserify

Version:

Browser-based tar utility for packing and unpacking tar files (stream-capable)

28 lines (27 loc) 954 B
import { ArchiveReader } from './archive-reader'; import { ArchiveWriter } from './archive-writer'; /** * Main entry point for extracting and creating tarballs. * See TarIterator and ArchiveEntry for more granular options. */ export class Archive extends ArchiveWriter { constructor(entries) { super(entries); } /** * Parses an Archive instance from the given buffer, with all entries read into memory. * The buffer should come from a complete, uncompressed tar file. */ static async extract(input) { const reader = ArchiveReader.withInput(input); const entries = await reader.readAllEntries(); return new Archive(entries); } /** * Iterate over entries in-place from a given source buffer. * The buffer should come from a complete, uncompressed tar file. */ static read(input) { return ArchiveReader.withInput(input); } }