Git Product home page Git Product logo

Comments (6)

pieroxy avatar pieroxy commented on July 19, 2024

LZ-String, as its name implies, is supposed to work on strings as input and strings as output. I am sure there are plenty of stream compressors out there that work much better than LZ-Strnig to compress a stream.

What usage did you have in mind for this feature ?

from lz-string.

mgcrea avatar mgcrea commented on July 19, 2024

@pieroxy, I'm currently working on a custom analytics solution that has to support partially offline devices (browsers) and be cross-platform. I've used IndexedDB (with a shim for iOS) to store the metrics.

Since there is a lot of redundancy in the data on the device that has to be posted back to the backend once online, I used your library to compress the data (using compressToUTF16 stored into a Uint16Array to be posted via xhr as binary data). Since the data is basically a huge JSON array, I was hoping to be able to nicely stream it to the LevelDB backend. Using something like on NodeJS :

var dbWriteStream = db.createWriteStream();
app.post('/collect', function(req, res) {
  req.pipe(lzUncompress).pipe(JSONStream.parse('rows.*')).pipe(dbWriteStream);
});

from lz-string.

pieroxy avatar pieroxy commented on July 19, 2024

Well... I don't really have time to do this these days, but I'm always glad to accept pull requests.

On an unrelated note, if you store your stuff in a Uint16Array, you probably don't need to worry about compressToUTF16 (which uses 15bits per char) and could achieve better encoding ratio by using compress directly.

from lz-string.

mgcrea avatar mgcrea commented on July 19, 2024

I was using compressToUTF16 since I'm using this on the server side:

    var string = buffer.toString('utf16le');
    string = LZString.decompressFromUTF16(string);

Did not manage to get it work using raw binary encoding.
Do you think I can still safely use compress directly with this setup?

I'm still getting my head around streams, but I might have a try, not sure how your algorithm works but do you think it could be easily adapted to handle streams? Or would it require to rewrite the algo?

from lz-string.

pieroxy avatar pieroxy commented on July 19, 2024

Sorry to have waited that long... Did you get your issue resolved ?

from lz-string.

pieroxy avatar pieroxy commented on July 19, 2024

Well, it's been a while. If I don't hear from you I'll just close this issue.

from lz-string.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.