read and write tar archives
0

Configure Feed

Select the types of activity you want to include in your feed.

39 1 0

Clone this repository

https://git.vm.fail/mary.my.id/pkg-tar https://git.vm.fail/did:plc:yu5qzw2pwxvv57534qtbkfce
ssh://git@knot1.tangled.sh:2222/mary.my.id/pkg-tar ssh://git@knot1.tangled.sh:2222/did:plc:yu5qzw2pwxvv57534qtbkfce

For self-hosted knots, clone URLs may differ based on your setup.


README.md

tar#

JSR | source code

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