Skip to main content

@std/tar@0.1.4
Built and signed on GitHub Actions

UNSTABLE: Streaming utilities for working with tar archives.

This package works with DenoIt is unknown whether this package works with Cloudflare Workers, Node.js, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
94%
Published
2 days ago (0.1.4)
class TarStream
Unstable

Overview

A TransformStream to create a tar archive. Tar archives allow for storing multiple files in a single file (called an archive, or sometimes a tarball). These archives typically have a single '.tar' extension. This implementation follows the FreeBSD 15.0 spec.

File Format & Limitations

The ustar file format is used for creating the tar archive. While this format is compatible with most tar readers, the format has several limitations, including:

  • Paths must be at most 256 characters.
  • Files must be at most 8 GiBs in size, or 64 GiBs if sizeExtension is set to true.
  • Sparse files are not supported.

Usage

TarStream may throw an error for several reasons. A few of those are:

  • The path is invalid.
  • The size provided does not match that of the iterable's length.

Compression

Tar archives are not compressed by default. If you'd like to compress the archive, you may do so by piping it through a compression stream.

Examples

Usage

import { TarStream, type TarStreamInput } from "@std/tar/tar-stream";

await ReadableStream.from<TarStreamInput>([
  {
    type: "directory",
    path: 'potato/'
  },
  {
    type: "file",
    path: 'deno.json',
    size: (await Deno.stat('deno.json')).size,
    readable: (await Deno.open('deno.json')).readable
  },
  {
    type: "file",
    path: '.vscode/settings.json',
    size: (await Deno.stat('.vscode/settings.json')).size,
    readable: (await Deno.open('.vscode/settings.json')).readable
  }
])
  .pipeThrough(new TarStream())
  .pipeThrough(new CompressionStream('gzip'))
  .pipeTo((await Deno.create('./out.tar.gz')).writable)

Constructors

new
TarStream()

Properties

The ReadableStream

The WritableStream

Add Package

deno add jsr:@std/tar

Import symbol

import { TarStream } from "@std/tar";

---- OR ----

Import directly with a jsr specifier

import { TarStream } from "jsr:@std/tar";

Add Package

npx jsr add @std/tar

Import symbol

import { TarStream } from "@std/tar";

Add Package

yarn dlx jsr add @std/tar

Import symbol

import { TarStream } from "@std/tar";

Add Package

pnpm dlx jsr add @std/tar

Import symbol

import { TarStream } from "@std/tar";

Add Package

bunx jsr add @std/tar

Import symbol

import { TarStream } from "@std/tar";