1/*
2Maybe string compression is the solution for you.
3This converts the data to byte arrays.
4
5There are multiple implementations and algorithms around, for instance
6
7LZMA-JS A standalone JavaScript implementation of the Lempel-Ziv-Markov chain (LZMA) compression algorithm.
8*/
9var str = "This is my compression test.";
10console.log("Size of sample is: " + str.length);
11var compressed = LZString.compress(str);
12console.log("Size of compressed sample is: " + compressed.length);
13str = LZString.decompress(compressed);
14console.log("Sample is: " + str);
15//solution 2
16my_lzma = new LZMA("./lzma_worker.js");
17my_lzma.compress("This is my compression test.", 1, function on_compress_complete(result) {
18 console.log("Compressed: " + result);
19 my_lzma.decompress(result, function on_decompress_complete(result) {
20 console.log("Decompressed: " + result);
21 }, function on_decompress_progress_update(percent) {
22 console.log("Decompressing: " + (percent * 100) + "%");
23 });
24}, function on_compress_progress_update(percent) {
25 console.log("Compressing: " + (percent * 100) + "%");
26});