question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Restore deflate `{ to: 'string' }` option on version 2

See original GitHub issue

Hello,

I’m currently using the following code with Pako 1.0.11:

pako.deflate(textEncode(source), { level: 9, to: 'string' })

I noticed that the option { to: 'string' } is not supported anymore on deflate (but still supported on inflate). The code to convert a buffer to a String is also still available at:

https://github.com/nodeca/pako/blob/45cce9f4d67dcd446e753a70ec31a56955ac20fc/lib/utils/strings.js#L99

So I’m wondering if this change is intended? And if by any chance we could restore this feature on deflate?

I can open a pull request with this change but first I want to make sure that we are in agreement 😄

Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ByordiShilpacommented, Oct 24, 2022

“It should NOT do such thing. I can not imagine context, where such operation is required and valid. Of cause, i can not prohibit you do that, but IMO such questions are out of this package scope.”

MediaWiki used the pako base64 output to send VisualEditor HTML back to the server. (which makes sense as uploads, unlike downloads, don’t support gzip)

Alternative uses are to store preferences (which can’t be some numbered array) or to store information in localStorage. (which can’t be some numbered array) Frankly, I can’t imagine context in which numbered arrays would be a useful output.

Converting these numbered arrays to base64-encodable strings is a pain as base64 only allows 1 byte per character. I tried out a bunch of stuff, but this is way too complicated and will not contribute to code I can really maintain.

I believe this change splits the pako userbase into three groups:

  1. “I will never update pako again and stick with 1.11”
  2. “Why are you forcing me to add code to make this work again?” (https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/refs/heads/master/resources/src/mediawiki.deflate/mw.deflate.js)
  3. “Let’s find an alternative to pako.”

It’s your project and you seem to have made your decision. But I wish you hadn’t just dropped a feature that -I’m guessing- 90%+ of your userbase relies on without providing a clear transition guide.

On the main page there is an example “Sometime you can wish to work with strings. For example, to send stringified objects to server.” but this example generates a Uint8Array which you can’t send to a server.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pako 2.1.0 API documentation
Pako's deflate detects input data type, and automatically recode strings to utf-8 prior to compress. Inflate has special option, to say ...
Read more >
How to decode deflate string in nodejs? - Stack Overflow
var options = { hostname: 'www.example.com', port: 80, path: '/deflateable-thing', method: 'GET' }; var req = http.request(options, function(res) ...
Read more >
zlib 1.2.13 Manual
deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if level is not a valid compression level, ...
Read more >
draft-preston-ftpext-deflate-03 - IETF Datatracker
It specifies a new "deflate" transmission mode designed to increase network bandwidth by compressing data using existing techniques. Table of Contents 1.
Read more >
IO::Compress::Deflate - Write RFC 1950 files/buffers
The string '-' can be used as an alias for standard input. ... This option applies to any input or output data streams...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found