I am trying to get LZ4 decompression to work client-side in pure JavaScript.
I found this JavaScript library but it's meant to be used with Node.js. Within the same repository I found a library which can in theory be used in the browser. The problem is that such library expects still Node.js buffers which again I don't have since I'm not using Node.js and all of this is happening client side (I logged a bug here to try and get a hold of some pointers for how to use it).
I then looked for a porting of Node.js buffers and I found this repository. The problem is that when I use it I get this error in both Chrome and Firefox:
TypeError: this is not a typed array
I logged this bug report for this. I feel like combining those two libraries I am not too far from achieving lz4 decompression in pure JavaScript but having never worked before with ArrayBuffer, Uint8Array and Node.js I am struggling to connect the dots.
My question: Has anyone successfully managed to decompress LZ4 in pure JavaScript? Any advice or pointers? Thanks in advance.
Node. JS is a toolkit built around Javascript, so yes, to get good at it would require Javascript knowledge.
To solve the "ReferenceError require is not defined" error, remove the type property if it's set to module in your package. json file and rename any files that have a . mjs extension to have a . js extension.
Compression in Node. js and Express decreases the downloadable amount of data that's served to users. Through the use of this compression, we can improve the performance of our Node. js applications as our payload size is reduced drastically. There are two methods of compression.
I will provide an IDEA not a solution, you can try this repository
https://code.google.com/p/lz4/
it has a pure c implementation of LZ4
you can compile that with clang to llvm bitcode
and when you have that, you use this https://github.com/kripken/emscripten
to get javascript out of the llvm bitcode
its like c to javascript compilation, it maybe sound crazy but if you look at what they already achieved... i dont know it could actually work.
take a look here they ported lots of things to javascript with this tool for example this one: https://github.com/kripken/lzma.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With