Restore deflate `{ to: 'string' }` option on version 2
See original GitHub issueHello,
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:
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:
- Created 3 years ago
- Reactions:1
- Comments:20 (9 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
https://stackoverflow.com/questions/12710001/how-to-convert-uint8-array-to-base64-encoded-string
“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:
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.