lzma-json
v1.0.0
Published
JavaScript LZMA implementation to efficiently compress JS objects into Blob that store very fast.
Downloads
2
Maintainers
Readme
lzma-json
Compress anything you can sum in a JSON into a Blob! Now with LZMA and web worker for multithreading. Thanks to Nathan Rugg and Matias Affolter.
import {LZMA} from "lzma-json";
let pool = null;
//import workerpool from "workerpool";
//let pool = workerpool.pool(null, {minWorkers: "max"});
blob.arrayBuffer().then((array_buffer) => {
const uint8a = new Uint8Array(array_buffer);
LZMA(uint8a, "DECOMPRESS_UINT8A", (obj) => {
// Get your javascript object back
}, pool);
}, pool);
LZMA(obj, "COMPRESS_OBJECT", (uint8a) => {
const blob = new Blob([uint8a], {type : "application/octet-stream"});
// Store a blob in a DB from your javascript object
}, pool);