or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

archive-control.mdarchive-creation.mdcontent-operations.mdformat-options.mdindex.md
tile.json

format-options.mddocs/

Format-Specific Options and Features

Detailed options and capabilities for each built-in archive format: ZIP, TAR, and JSON.

ZIP Format

ZIP format provides compressed archive support with configurable compression levels and various ZIP-specific options.

ZIP Format Options

/**
 * ZIP format-specific options
 */
interface ZipOptions {
  /** ZIP archive comment */
  comment?: string;
  /** Use local time instead of UTC (default: false) */
  forceLocalTime?: boolean;
  /** Force ZIP64 headers for large archives (default: false) */
  forceZip64?: boolean;
  /** Prepend slash to entry paths (default: false) */
  namePrependSlash?: boolean;
  /** Use STORE compression - no compression (default: false) */
  store?: boolean;
  /** Options passed to zlib for compression */
  zlib?: {
    /** Compression level 0-9 (0=no compression, 9=max compression) */
    level?: number;
    /** Chunk size for compression */
    chunkSize?: number;
    /** Window bits for compression */
    windowBits?: number;
    /** Memory level for compression */
    memLevel?: number;
    /** Compression strategy */
    strategy?: number;
  };
}

ZIP Entry-Specific Options

/**
 * ZIP entry-specific options (extends base EntryData)
 */
interface ZipEntryData extends EntryData {
  /** Override global store setting for this entry */
  store?: boolean;
  /** Override global namePrependSlash setting for this entry */
  namePrependSlash?: boolean;
}

ZIP Usage Examples

const archiver = require('archiver');

// Maximum compression ZIP archive
const zipMax = archiver('zip', {
  zlib: { level: 9 } // Maximum compression
});

// Fast compression with custom options
const zipFast = archiver('zip', {
  zlib: { 
    level: 1,      // Fast compression
    chunkSize: 1024,
    windowBits: 15,
    memLevel: 8
  },
  comment: 'Generated by my application',
  forceLocalTime: true
});

// No compression (store only)
const zipStore = archiver('zip', {
  store: true // No compression, fastest
});

// ZIP64 for large archives
const zipLarge = archiver('zip', {
  forceZip64: true, // Support archives > 4GB
  zlib: { level: 6 }
});

// Adding entries with ZIP-specific options
zipMax.append('content', { 
  name: 'file.txt',
  store: false // Compress this entry even if global store is true
});

zipMax.append('binary data', { 
  name: 'data.bin',
  store: true, // Don't compress this entry
  namePrependSlash: true // Force slash prefix
});

ZIP Supported Features

  • Directories: ✓ Supported
  • Symbolic Links: ✓ Supported
  • Compression: ✓ Configurable levels (0-9)
  • Large Files: ✓ ZIP64 support
  • Comments: ✓ Archive-level comments

TAR Format

TAR (Tape Archive) format provides uncompressed archive support with optional gzip compression.

TAR Format Options

/**
 * TAR format-specific options
 */
interface TarOptions {
  /** Compress TAR using gzip (default: false) */
  gzip?: boolean;
  /** Options passed to zlib.createGzip() when gzip is true */
  gzipOptions?: {
    /** Compression level 0-9 */
    level?: number;
    /** Chunk size for compression */
    chunkSize?: number;
    /** Window bits for compression */
    windowBits?: number;
    /** Memory level for compression */
    memLevel?: number;
    /** Compression strategy */
    strategy?: number;
  };
}

TAR Entry Options

/**
 * TAR entry options (extends base EntryData)
 */
interface TarEntryData extends EntryData {
  /** Entry type: 'file', 'directory', 'symlink' */
  type?: 'file' | 'directory' | 'symlink';
  /** For symlink entries, the target path */
  linkname?: string;
}

TAR Usage Examples

const archiver = require('archiver');

// Plain TAR archive (no compression)
const tar = archiver('tar');

// TAR with gzip compression
const tarGz = archiver('tar', {
  gzip: true,
  gzipOptions: {
    level: 6,     // Balanced compression
    chunkSize: 1024
  }
});

// TAR with maximum gzip compression
const tarGzMax = archiver('tar', {
  gzip: true,
  gzipOptions: {
    level: 9      // Maximum compression
  }
});

// Adding entries to TAR (same as other formats)
tarGz
  .append('Hello TAR', { name: 'hello.txt' })
  .file('/path/to/file', { name: 'archived-file.txt' })
  .directory('/path/to/dir', 'archived-dir');

TAR Supported Features

  • Directories: ✓ Supported
  • Symbolic Links: ✓ Supported
  • Compression: ✓ Optional gzip compression
  • Large Files: ✓ No size limits
  • Standards: ✓ POSIX.1-1988 (ustar) format

JSON Format

JSON format provides metadata-only archiving, outputting entry information as structured JSON data.

JSON Format Options

/**
 * JSON format options (uses base Transform options only)
 */
interface JsonOptions {
  // No format-specific options beyond base Transform stream options
  highWaterMark?: number;
  objectMode?: boolean;
}

JSON Entry Data

/**
 * JSON entry data with automatically calculated fields
 */
interface JsonEntryData extends EntryData {
  /** Entry type: 'file', 'directory', 'symlink' */
  type?: 'file' | 'directory' | 'symlink';
  /** CRC32 checksum of entry content (automatically calculated) */
  crc32?: number;
  /** Size of entry content in bytes (automatically calculated) */
  size?: number;
  /** For symlink entries, the target path */
  linkname?: string;
}

JSON Output Format

The JSON format outputs an array of entry metadata objects:

[
  {
    "name": "file.txt",
    "date": "2023-01-01T12:00:00.000Z",
    "mode": 33188,
    "crc32": 123456789,
    "size": 11,
    "type": "file"
  },
  {
    "name": "directory/",
    "date": "2023-01-01T12:00:00.000Z",
    "mode": 16877,
    "type": "directory"
  }
]

JSON Usage Examples

const archiver = require('archiver');
const fs = require('fs');

// Create JSON metadata archive
const jsonArchive = archiver('json');
const output = fs.createWriteStream('metadata.json');

jsonArchive.pipe(output);

// Add various content types
jsonArchive
  .append('Hello World', { name: 'hello.txt' })
  .file('/path/to/document.pdf', { name: 'document.pdf' })
  .directory('/path/to/images', 'images')
  .symlink('link.txt', 'target.txt');

jsonArchive.finalize().then(() => {
  console.log('JSON metadata archive created');
  // Output file contains JSON array with entry metadata
});

// Reading the JSON output
jsonArchive.on('data', (chunk) => {
  // JSON data is streamed as it's generated
  console.log('JSON chunk:', chunk.toString());
});

JSON Supported Features

  • Directories: ✓ Supported (metadata only)
  • Symbolic Links: ✓ Supported (metadata only)
  • Checksums: ✓ Automatic CRC32 calculation
  • Size Information: ✓ Automatic size calculation
  • Metadata Only: ✓ No actual file content stored

Format Comparison

FeatureZIPTARJSON
Compression✓ (zlib)✓ (gzip)
Directories✓ (metadata)
Symlinks✓ (metadata)
Large Files✓ (ZIP64)✓ (metadata)
StandardsZIP 2.0+POSIX.1-1988JSON
Use CasesGeneral archivesUnix/Linux archivesMetadata analysis
File Content✗ (metadata only)

Error Handling

Format-specific errors that may be thrown:

  • DIRECTORYNOTSUPPORTED - Format doesn't support directory entries
  • SYMLINKNOTSUPPORTED - Format doesn't support symlink entries
  • ENTRYNOTSUPPORTED - Entry type not supported by format

Performance Considerations

ZIP Format

  • Higher compression levels (7-9) use more CPU but produce smaller files
  • store: true option provides fastest processing with no compression
  • ZIP64 has small overhead but supports unlimited file sizes

TAR Format

  • Plain TAR is fastest for archiving without compression
  • Gzip compression adds CPU overhead but reduces file size
  • Most compatible format across Unix/Linux systems

JSON Format

  • Fastest format as it only processes metadata
  • Useful for cataloging and analysis without storing actual content
  • Minimal memory usage as no content is buffered