Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/archive/tar.ts>Tar

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
class Tar
import { Tar } from "https://deno.land/std@0.194.0/archive/tar.ts";

A class to create a tar archive

Examples

Example 1

import { Tar } from "https://deno.land/std@0.194.0/archive/tar.ts";
import { Buffer } from "https://deno.land/std@0.194.0/io/buffer.ts";
import { copy } from "https://deno.land/std@0.194.0/streams/copy.ts";

const tar = new Tar();
const content = new TextEncoder().encode("Deno.land");
await tar.append("deno.txt", {
  reader: new Buffer(content),
  contentSize: content.byteLength,
});

// Or specifying a filePath.
await tar.append("land.txt", {
  filePath: "./land.txt",
});

// use tar.getReader() to read the contents.

const writer = await Deno.open("./out.tar", { write: true, create: true });
await copy(tar.getReader(), writer);
writer.close();

Constructors

new
Tar()

Methods

append(fn: string, opts: TarOptions)

Append a file to this tar archive

Get a Reader instance for this tar data