@simonekruegel/brar
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

Brotli Archive Library

Install

npm i @simonekruegel/brar

Usage

import BrarManager from '@simonekruegel/brar'

// Open archive
const manager = new BrarManager('./some-archive.brar')

// Add file to archive
manager.addFile('/some-path.txt', someBuffer) // someBuffer needs to be Node.js Buffer

// Write and compress the archive
manager.save()

// Load an existing archive
manager.load()

// Retrieve the decompressed data of the file
const data = manager.getFile('/some-path.txt')

Specification

All ints are Big Endian (BE)

{# HEADER
    4 Bytes                      = String  = "BRAR" (utf8)
    4 Bytes                      = Uint32  = File Count
    4 Bytes                      = Uint32  = File Table Offset
    4 Bytes                      = Uint32  = File Table Size
    4 Bytes                      = Uint32  = File Table Size (Compressed)
#}

{# BODY
    { For File Count {
        { Compressed (brotli)
            {File Size (Compressed)} Bytes        = Uint8[] = File Data
        }
    }}
#}

{# FILE TABLE
    { Compressed (brotli)
        { For File Count {
            4 Bytes                  = Uint32  = File Name Length
            {File Name Length} Bytes = String  = File Name (utf8)
            4 Bytes                  = Uint32  = File Offset
            4 Bytes                  = Uint32  = File Size
            4 Bytes                  = Uint32  = File Size (Compressed)
        }}
    }
#}

Readme

Keywords

Package Sidebar

Install

npm i @simonekruegel/brar

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

15.8 kB

Total Files

13

Last publish

Collaborators

  • simonekruegel