npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@obsidize/tar-browserify

v6.3.2

Published

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

Readme

@obsidize/tar-browserify

Simple utility for packing and unpacking tar files in the browser.

Highlights:

  • Zero dependencies
  • No node-based requires/imports (fully compatible in browser)
  • Inline extraction tools (examples below)
  • Builder pattern for creating tarball files in-memory (examples below)
  • Supports PAX header reading/writing

Pairs well with these modules:

Installation

npm install -P -E @obsidize/tar-browserify

Usage

Read a tar file

import { ungzip } from 'pako';
import { Archive } from '@obsidize/tar-browserify';

async function readTarFile() {
	const response = await fetch('url/to/some/file.tar.gz');
	const gzBuffer = await response.arrayBuffer();
	const tarBuffer = ungzip(gzBuffer);

	for await (const entry of Archive.read(tarBuffer)) {
		if (entry.isFile()) {
			console.log(`read tar file: ${entry.fileName} with content length ${entry.content!.byteLength}`);
			console.log(`file text contents: ${entry.text()}`);
			// TODO: do something interesting with the file
		}
	}
}

readTarFile().catch(console.error);

Write a tar file

import { gzip } from 'pako';
import { Archive } from '@obsidize/tar-browserify';

async function writeTarFile() {
	const tarBuffer = new Archive()
		.addDirectory('MyStuff')
		.addTextFile('MyStuff/todo.txt', 'This is my TODO list')
		.addBinaryFile('MyStuff/some-raw-file.obj', Uint8Array.from([1, 2, 3, 4, 5]))
		.addDirectory('Nested1')
		.addDirectory('Nested1/Nested2')
		.addBinaryFile('Nested1/Nested2/supersecret.bin', Uint8Array.from([6, 7, 8, 9]))
		.toUint8Array();

	const gzBuffer = gzip(tarBuffer);
	const fileToSend = new File([gzBuffer], 'my-awesome-new-file.tar.gz');
	// TODO: send the new file somewhere
}

writeTarFile().catch(console.error);

Modify an existing tar file

import { gzip, ungzip } from 'pako';
import { Archive } from '@obsidize/tar-browserify';

async function modifyTarFile() {
	const response = await fetch('url/to/some/file.tar.gz');
	const gzBuffer = await response.arrayBuffer();
	const tarBuffer = ungzip(gzBuffer);
	const archive = await Archive.extract(tarBuffer);

	const updatedTarBuffer = archive
		.removeEntriesWhere((entry) => /unwanted\-file\-name\.txt/.test(entry.fileName))
		.cleanAllHeaders() // remove unwanted metadata
		.addTextFile('new text file.txt', 'this was added to the original tar file!')
		.toUint8Array();

	const updatedGzBuffer = gzip(updatedTarBuffer);
	const fileToSend = new File([updatedGzBuffer], 'my-awesome-edited-file.tar.gz');
	// TODO: send the modified file somewhere
}

modifyTarFile().catch(console.error);

Read a BIG tar file (Advanced)

For very large files (>= 50MB) it is better to use the AsyncUint8ArrayLike interface for loading the file in chunks (either from disk or over a network)

import { Archive, AsyncUint8ArrayLike } from '@obsidize/tar-browserify';

async function readBigTarFile() {
  const customAsyncBuffer: AsyncUint8ArrayLike = {
    byteLength: 12345, // the file length in bytes must be known ahead of time
    read: (offset: number, length: number): Promise<Uint8Array> => /* TODO: return chunk from disk or network request */
  };

  for await (const entry of Archive.read(customAsyncBuffer)) {
    if (!entry.isFile()) {
      continue;
    }

	let totalBytesRead = 0;

	for await (const chunk of entry.getContentChunks()) {
	  totalBytesRead += chunk.byteLength;
      // TODO: do something interesting with the data chunk
	}
  }
}

readBigTarFile().catch(console.error);

API

Full API docs can be found in the repo GitHub Docs Page

Testing

This module has a full Test Suite to ensure breaking changes are not introduced, and is tested against the output of the node-tar package to ensure stability.

  • npm test - run unit tests with live-reload.
  • npm run coverage - perform a single-pass of unit tests with code-coverage display.