DeflateX is a Haxe port of the deflate implementation written by RidgeX (hence the "X" in the name). Written purely in Haxe without any additional dependencies, it compiles to all available targets, but was tested only for JS, Flash, C++ (Windows), C# (Windows), PHP, Java, and HashLink.
Usage
DeflateX can be used to apply both deflate and inflate algorithms, but also to compress and decompress gzip file format.
Using DeflateX is pretty straightforward. If you want to compress a byte array simply pass it into the static Deflater.apply method.
var test:String = "Test data 123";
var test_bytes:Bytes = Bytes.ofString(test);
var compressed:Bytes = Deflater.apply(test_bytes);;
However, in case you're working in a multi-threaded environment and want to run multiple deflate operations in parallel, you can also instantiate a unique Deflater object and call compress method instead:
var deflater:Deflater = new Deflater();
var compressed:Bytes = deflater.compress(test_bytes);
Once a byte array is deflated you can decompress it using the static Inflater.apply method:
var decompressed:Bytes = Inflater.apply(compressed);
var result:String = decompressed.getString(0, decompressed.length);
trace(result); //following the Usage steps this should output "Test data 123"
Or similarly as with Deflater by instating the Inflater object and calling the decompress method:
var inflater:Inflater = new Inflater();
var decompressed:Bytes = inflater.decompress(compressed);