1
0
Fork
You've already forked pkg-tar
0
Read and write tar archives https://jsr.io/@mary/tar
  • TypeScript 100%
2026年01月24日 15:45:16 +07:00
.vscode initial commit 2024年03月02日 10:37:29 +07:00
lib refactor: remove for-await in TarEntry#body 2026年01月24日 15:44:58 +07:00
samples feat: add tests 2024年03月06日 20:44:18 +07:00
deno.json v0.3.2 2026年01月24日 15:45:16 +07:00
deno.lock chore: update lockfile 2024年03月11日 05:26:46 +07:00
LICENSE initial commit 2024年03月02日 10:37:29 +07:00
README.md docs: update readme 2024年03月25日 22:51:10 +07:00
test.ts chore: move library code to lib folder 2024年03月12日 15:07:57 +07:00

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