Giter Club home page Giter Club logo

Comments (8)

Rycochet avatar Rycochet commented on August 28, 2024

Been hitting this myself for both raw compression and uint8array compression - and if it is the same then it's an issue with NodeJS loading them again - and turning the Buffer back into usable raw data. Using any of the other (current) modes works perfectly well and has no issues, so I hope that someone sees this and has a look at it (specifically bin/cli.cjs - as soon as it works the test.sh script will have them passing, as it can save data perfectly well!)

from lz-string.

karnthis avatar karnthis commented on August 28, 2024

How is the grab for decompression being done? pretty much all if not all of the built in methods of reading data into the buffer sanitizes it into a "safe" string with things like control characters and such removed or escaped.

I had to write my own functions to handle this process for my projects, maybe something similar as a helper suite would be worth adding to the main library?

from lz-string.

Rycochet avatar Rycochet commented on August 28, 2024

That's pretty much the problem, the raw.bin for tattoo (test suite) is 972 bytes, if loading in NodeJS (via readFileSync) it gives a ~1092 byte (this I cant remember so well) string, but buffer.byteLength gives the correct 972 bytes - I've tried various combinations of TextDecoder and manual iterations, and can't end up with a 972 byte String to pass to stock/decode - a lot of testing (and the internal validation) shows that everything including the file writing is correct, just that re-loading step that fails.

Have you got a public repo to show how you managed it?

from lz-string.

karnthis avatar karnthis commented on August 28, 2024

Yeah the functions are defined here: https://github.com/JackalLabs/jackal.js/blob/v3-upgrade/src/utils/converters.ts#L100

stringToUint8Array and stringToUint16Array

the functions are used in a few places both on compressed strings and standard ones.

from lz-string.

Rycochet avatar Rycochet commented on August 28, 2024

It's going the other way around that has a problem - NodeJS loads as a Buffer (basically a Uint8array), and converting that to a string has a problem :-/

from lz-string.

karnthis avatar karnthis commented on August 28, 2024

I thought the on-disk saved version was the issue? anyway, this handles conversion from a buffer-like to a string.

https://github.com/JackalLabs/jackal.js/blob/v3-upgrade/src/utils/converters.ts#L70

I did some experimenting before moving on due to time crunch, but I think Node actually uses a bastardized utf. buffer <> string doesn't comply 1:1 with the behavior we see in the browser.

from lz-string.

Rycochet avatar Rycochet commented on August 28, 2024

It does something weird - I'd actually tried that one without the spread - will give that a try later when I get a chance - I've specifically told it null for encoding so it doesn't try to utf8 it, but I don't know what it's doing :-/

from lz-string.

Rycochet avatar Rycochet commented on August 28, 2024

Finally managed to figure it out - treating data as potential Uint8Array, but that it might have an odd number of characters - included here, and used for decompressing uint8array as that supports more, but encoding is a breaking change (as it now supports non-even -length data)

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.