bzip2 is a file format and a software application used for file compression and decompression that uses the Burrows–Wheeler algorithm.

bzip2 compresses most files more effectively than the older LZW (.Z) and Deflate (.zip and .gz) compression algorithms, but is considerably slower.

bzip2 compresses data in blocks of size between 100 and 900 kB and uses the Burrows–Wheeler transform to convert frequently-recurring character sequences into strings of identical letters. It then applies move-to-front transform and Huffman coding. bzip2's ancestor bzip used arithmetic coding instead of Huffman.

1 Compress and uncompress a resource

    let file = new"/tmp/sample.txt");
    file.append(`Lorem ipsum dolor sit amet, consectetur adipiscing elit, 
        sed eiusmod tempor incidunt ut labore et dolore magna aliqua.`);

    var bzip2 = new;

    var src  = new"/tmp/sample.txt");
    var dst  = new"/tmp/sample.bz2");
    var tmp  = new"/tmp/sample.txt");
    console.log(src + " " + src.length() + " byte(s)");
    console.log(dst + " " + dst.length() + " byte(s)");

    console.log(tmp + " " + tmp.length() + " byte(s)");
/etc/services 677972 byte(s)
/tmp/services.bz2 164677 byte(s)
/tmp/services.tmp 677972 byte(s)