### ----------------------------------------------------
### -- Compress::Bzip2
### -- Licenses: Artistic-2.0
### -- Authors: 
### -- File: README.md
### ----------------------------------------------------
perl6-Compress-Bzip2
[![Linux](https://github.com/Altai-man/perl6-Compress-Bzip2/actions/workflows/linux.yml/badge.svg)](https://github.com/Altai-man/perl6-Compress-Bzip2/actions/workflows/linux.yml) [![MacOS](https://github.com/Altai-man/perl6-Compress-Bzip2/actions/workflows/macos.yml/badge.svg)](https://github.com/Altai-man/perl6-Compress-Bzip2/actions/workflows/macos.yml) [![Windows](https://github.com/Altai-man/perl6-Compress-Bzip2/actions/workflows/windows.yml/badge.svg)](https://github.com/Altai-man/perl6-Compress-Bzip2/actions/workflows/windows.yml)
====================

Bindings to bzip2 library. Procedural API is as easy as pie: you can compress and decompress your files like this:

```perl6
compress($filename);
decompress($filename);
```

If you want to make a simple "from Buf to Buf" (de)compressing, you should use something like this:

```perl6
my buf8 $result = compressToBlob($data); # Data should be encoded.
# or
my Str $result = decompressToBlob($compressed-data).decode;
```

Also, now we support streaming:

```perl6
my $compressor = Compress::Bzip2::Stream.new;
loop {
     $socket.write($compressor.compress($data-chunk));
}
$socket.write($compressor.finish);

my $dcompressor = Compress::Bzip2::Stream.new;
while !$dcompressor.finished {
      my $data-chunk = $dcompressor.decompress($socked.read($size));
}
```

Your any suggestions, reporting of issues and advices about design of library will be really helpful.

I'm very grateful to authors of perl6 bindings to zlib compression library, since I took their code as example for this work and wrote very similar interface.

TODO
====================

* Docs.


