Building a TAR archive in the browser with about 100 lines of TypeScript
A developer explains how to write TAR files by hand in the browser, arguing the format is simple enough to be a good learning exercise compared with the more common ZIP. A TAR archive is a series of 512-byte blocks, with a header per file, zero-padded data, and two empty blocks at the end, and it has no compression or index of its own. The header uses ASCII octal numbers and includes a checksum computed with that field treated as spaces. The approach wraps File objects in a Blob without loading them into memory, so large inputs stay manageable. The author notes edge cases such as names longer than 100 bytes, UTF-8 byte lengths, and directory entries, and says the browser's built-in gzip support can produce .tar.gz output.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in