js-string-compression
js-string-compression copied to clipboard
Decompress wrong with data JSON.stringify
Code
var jsscompress = require("js-string-compression");
var raw_text = `{"data":"test"}`;
var hm = new jsscompress.Hauffman();
var compressed = hm.compress(raw_text);
console.log("before compressed: " + raw_text);
console.log("length: " + raw_text.length);
console.log("length: " + compressed.length);
console.log("decompressed: " + hm.decompress(compressed));
Output
before compressed: {"data":"test"}
raw length: 15
compressed length: 17
decompressed: {"data":"test"}t
decompressed length: 16
Expected:
before compressed: {"data":"test"} raw length: 15 compressed length: <=15 decompressed: {"data":"test"} decompressed length: 15
In this case, compressed length > before compressed!