Skip to main content

Read and write tar archives

Works with
This package works with Bun
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Browsers
JSR Score
100%
Published
2 months ago (0.2.4)

tar

Read and write tar archives.

// `writeTarEntry` is designed to be very simplistic, as the name suggests, it
// only spits out a buffer for one file entry. Good for streaming writes, but
// means you'd have to concatenate it yourself if you're doing it in one go.

const buffer = writeTarEntry({
	name: 'README.md',
	data: `Hello, **world**!`,
});

// `untar` lets you iterate over a tar archive, it's streamed, so you'd need to
// pass a readable stream.

for await (const entry of untar(stream)) {
	// If it's a file in the blobs directory...
	if (entry.name.startsWith('blobs/')) {
		const buffer = await entry.arrayBuffer();
		// -> ArrayBuffer(...)
	}
}

Add Package

deno add @mary/tar

Import symbol

import * as mod from "@mary/tar";

Add Package

npx jsr add @mary/tar

Import symbol

import * as mod from "@mary/tar";

Add Package

yarn dlx jsr add @mary/tar

Import symbol

import * as mod from "@mary/tar";

Add Package

pnpm dlx jsr add @mary/tar

Import symbol

import * as mod from "@mary/tar";

Add Package

bunx jsr add @mary/tar

Import symbol

import * as mod from "@mary/tar";