Comments (8)
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.
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.
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.
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.
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.
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.
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.
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)
- Crash with large strings when running on Hermes (React Native)
- Is there a way to allow custom dictionaries? HOT 9
- How to realize that only specified characters are allowed to appear in the compression result? HOT 1
- LZ-String port to current typescript HOT 9
- Tag for v1.5.0 HOT 2
- Version 2 TODO list HOT 15
- Feature request: compress to source-compatible character set HOT 1
- New port for a linux executable HOT 1
- Can utf-8 codes be avoided in the output? HOT 10
- `decompressFromBase64` can return `null` HOT 7
- Docs: JSPerf.com links are no longer valid
- Docs: A Complete Demo for various compression/decompression HOT 3
- Docs: TSDoc HOT 3
- License Inconsistencies HOT 5
- Community Question: Breaking Changes and Version 2! HOT 10
- [email protected] build with warnings HOT 4
- Feature request: a non minified js file as a result of building v2 HOT 2
- Chrome virus warning with compressToEncodedURIComponent URL HOT 2
- CLI support for decompressing base64 encoded files HOT 1
- Please investigate the slow (irresponsible) LZString issue in Edge HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lz-string.