Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/markknol/hx-lzstring
LZString port in Haxe
https://github.com/markknol/hx-lzstring
compression compression-algorithm encryption encryption-algorithm haxe
Last synced: 14 days ago
JSON representation
LZString port in Haxe
- Host: GitHub
- URL: https://github.com/markknol/hx-lzstring
- Owner: markknol
- Created: 2019-04-11T08:02:36.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-07-16T07:42:22.000Z (over 5 years ago)
- Last Synced: 2024-11-25T06:52:09.374Z (3 months ago)
- Topics: compression, compression-algorithm, encryption, encryption-algorithm, haxe
- Language: Haxe
- Size: 17.6 KB
- Stars: 8
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# LZString
[![Build Status](https://travis-ci.org/markknol/hx-lzstring.svg?branch=master)](https://travis-ci.org/markknol/hx-lzstring) [![Haxelib Version](https://img.shields.io/github/tag/markknol/hx-lzstring.svg?label=haxelib)](http://lib.haxe.org/p/lzstring)
**LZ-based compression algorithm for Haxe.**This is a port of 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
* [Haxe](https://haxe.org/) 4.0+
### 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.
```haxe
import lzstring.LZString;
```#### API
```haxe
compress(uncompressed:String):String
compressToBase64(input:String):String
compressToEncodedURIComponent(input:String):String
compressToUint8Array(uncompressed:String):UInt8Array
compressToUTF116(input:String):Stringdecompress(compressed:String):String
decompressFromBase64(input:String):String
decompressFromEncodedURIComponent(input:String):String
decompressFromUint8Array(compressed:UInt8Array):String
decompressFromUTF116(compressed:String):String
```#### Usage
```haxe
var input = "aaaaabaaaaacaaaaadaaaaaeaaaaaaa";
var l = new LZString();var compressed = l.compress(input);
trace(compressed); // ↉ࣔä†ã „혅㖈耀var decompressed = l.decompress(compressed);
trace(decompressed); // aaaaabaaaaacaaaaadaaaaaeaaaaaaatrace(input == decompressed); // true
```#### Base64
```haxe
var input = "aaaaabaaaaacaaaaadaaaaaeaaaaaaa";
var l = new LZString();
var compressed = l.compressToBase64(input);
trace(compressed); // IYkI1EGNOATWBTWIg===var decompressed = l.decompressFromBase64(compressed);
trace(decompressed); // aaaaabaaaaacaaaaadaaaaaeaaaaaaatrace(input == decompressed); // true
```### Run test
Clone the repository and run
```
haxe test.hxml
```