https://github.com/copy/jslzjb-k
Fast compression for JavaScript (browser and node)
https://github.com/copy/jslzjb-k
compression javascript lzjb
Last synced: about 1 year ago
JSON representation
Fast compression for JavaScript (browser and node)
- Host: GitHub
- URL: https://github.com/copy/jslzjb-k
- Owner: copy
- License: bsd-3-clause
- Created: 2015-05-18T18:52:36.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2016-07-17T19:45:11.000Z (about 10 years ago)
- Last Synced: 2025-03-25T15:03:11.398Z (over 1 year ago)
- Topics: compression, javascript, lzjb
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 28
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
jslzjb-k
=
This is a fork of the jslzjb project, https://code.google.com/p/jslzjb/
It has been modified to work on `Uint8Array` values exclusively and avoids all
allocations during compression and decompression. These changes have been made
out of the need to compress large buffers in a reasonable amount of time.
It performs compression of a 100 MB buffer in the order of a second.
Test it yourself:
```
% ./test-lzjb.js test-lzjb.js
compress: 0.822ms
decompress: 0.281ms
compressed test-lzjb.js from=905 to=659
% ./test-lzjb.js /bin/node
compress: 106.155ms
decompress: 55.874ms
compressed /bin/node from=14059k to=9348k
```
Two methods are exported:
```javascript
/**
* Compress byte array using fast and efficient algorithm.
*
* @param {Uint8Array} sstart The buffer to compress
* @param {Uint8Array} dstart The buffer to write into
* @return {number} compressed length (number of bytes written to the
* output buffer). May be bigger than the size of the
* output buffer, in which case some bytes are lost
*/
jslzjb.compress = function(sstart, dstart)
/**
* Decompress byte array using fast and efficient algorithm.
*
* @param {Uint8Array} sstart The buffer to decompress
* @param {number} slen compressed length
* @param {Uint8Array} dstart The buffer to write into
* @return {number} decompressed length
*/
jslzjb.decompress = function(sstart, slen, dstart)
```
**TODO**
- Benchmarks
- Make use of asm.js
- Make use of simd