lzstring

Port of LZString.js for Haxe 4.0+
https://github.com/markknol/hx-lzstring/

To install, run:

haxelib install lzstring 0.0.1 

See using Haxelib in Haxelib documentation for more information.

README.md

LZString

Build Status Haxelib Version

LZ-based compression algorithm for Haxe.

This is a port of lz-string https://github.com/pieroxy/lz-string. More info about the library can be found here http://pieroxy.net/blog/pages/lz-string/index.html.

This library should run on all Haxe targets. (but is mostly tested in JavaScript and Macro context).

Dependencies

Install the library for your project

Install the library using haxelib

haxelib install lzstring

And add this to your compile arguments / build hxml file

-lib lzstring

Using the library

Import the library in your code.

import lzstring.LZString;

And add this to your compile arguments / build hxml file

API

compress(uncompressed:String):String
compressToBase64(input:String):String
compressToEncodedURIComponent(input:String):String
compressToUint8Array(uncompressed:String):UInt8Array
compressToUTF116(input:String):String

decompress(compressed:String):String
decompressToBase64(input:String):String
decompressToEncodedURIComponent(input:String):String
decompressToUint8Array(compressed:UInt8Array):String
decompressToUTF116(compressed:String):String

Usage

var input = "aaaaabaaaaacaaaaadaaaaaeaaaaaaa";
var l = new LZString();

var compressed = l.compress(input);
trace(compressed);  // ↉ࣔ䆍㠄혅㖈耀

var decompressed = l.decompress(compressed);
trace(decompressed); // aaaaabaaaaacaaaaadaaaaaeaaaaaaa

trace(input == decompressed); // true

Base64

var input = "aaaaabaaaaacaaaaadaaaaaeaaaaaaa";
var l = new LZString();
var compressed = l.compressToBase64(input);
trace(compressed); // IYkI1EGNOATWBTWIg===

var decompressed = l.decompressFromBase64(compressed);
trace(decompressed); // aaaaabaaaaacaaaaadaaaaaeaaaaaaa

trace(input == decompressed); // true

Run test

Clone the repository and run

haxe test.hxml
Contributors
markknol
Version
0.0.1
Published
7 years ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub