d5ly
v1.2.3
Published
Deflate compression library based WebAssembly
Downloads
6
Maintainers
Readme
D5LY - npm
The fastest deflate compressor in npm
Usage
With npm installed, run:
$ npm install d5ly
Then use:
For React:
import d5ly from 'd5ly'
For NodeJS:
d5ly = require('d5ly')
Then:
if you sure, that wasm already had time to initialize, you can only use:
var sourceArray = new Uint8Array(1000000);
sourceArray[4] = 45;
sourceArray[9] = 32;
console.log(sourceArray);
var compressedArray = d5ly.deflateCompress(sourceArray);
console.log(compressedArray);
var decompressedArray = d5ly.deflateDecompress(compressedArray);
console.log(decompressedArray);
compressedArray = d5ly.zlibCompress(sourceArray);
console.log(compressedArray);
decompressedArray = d5ly.zlibDecompress(compressedArray);
console.log(decompressedArray);
compressedArray = d5ly.gzipCompress(sourceArray);
console.log(compressedArray);
decompressedArray = d5ly.gzipDecompress(compressedArray);
console.log(decompressedArray);
You can check, if the wasm have been intialized by function:
d5ly.isInit();
If you don't sure, thst the wasm have been initialized, you should put your code into callback:
d5ly.onInitAdd(()=> {
console.log('start');
var sourceArray = new Uint8Array(1000000);
sourceArray[4] = 45;
sourceArray[9] = 32;
console.log(sourceArray);
var compressedArray = d5ly.deflateCompress(sourceArray);
console.log(compressedArray);
var decompressedArray = d5ly.deflateDecompress(compressedArray);
console.log(decompressedArray);
compressedArray = d5ly.zlibCompress(sourceArray);
console.log(compressedArray);
decompressedArray = d5ly.zlibDecompress(compressedArray);
console.log(decompressedArray);
compressedArray = d5ly.gzipCompress(sourceArray);
console.log(compressedArray);
decompressedArray = d5ly.gzipDecompress(compressedArray);
console.log(decompressedArray);
});
Speed test in compare with pako and wasm-flate: