Please provide (minimal) client-side examples
See original GitHub issueIn my case, I want to unzip some gzipped strings. What are the minimum steps I need to do this client side / browser?
I don’t understand which files I need.
I would expect justdist/pako_deflate.min.js
but it requires files not in the dist
directory.
Please provide a minimal example. Cooler would be examples for decode too, in the README.MD
, but that’s just thinking about other people who stumble across this interesting module - not for me.
ps I am using requirejs
if that makes things easier.
Issue Analytics
- State:
- Created 9 years ago
- Comments:27 (9 by maintainers)
Top Results From Across the Web
How to create a Minimal, Reproducible Example - Help Center
Don't sacrifice clarity for brevity when creating a minimal example. Use consistent naming and indentation, and include code comments if needed. Use your...
Read more >Introduction to client-side frameworks - Learn web development
Objective: To understand how client-side JavaScript frameworks came to exist, ... Popular examples include Wordpress, Joomla, and Drupal.
Read more >10 Client-side Storage Options and When to Use Them
Storing and manipulating data in the browser — also known as client-side storage — is useful when it's not necessary or practical to...
Read more >Minimal client-side CRUD example (add, edit, delet buttons)
Does anyone know of a minimal example including buttons to Add empty row Edit row Delete row ? ... Can you please send...
Read more >Client-side Scripting Techniques for WCAG 2.0 - W3C
This example is limited to client-side scripting, and should be backed up with server-side validation. The example is limited to the creation of...
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
@ixti I’ve already read the Examples and read the API you mention. Where do you think I’ve been those two hours before reopening? Clearly, they aren’t helping me.
It’s typical how certain developers often want to share their code, but not their knowledge by systematically refusing to symphatize with less seasoned developers who run into a (small) problem that can easily be avoided by a simple® example.
They rather see a thousand users waste half a day, than improve documentation with a simple usecase. Every developer knows other developers are clever enough to interpolate from there to the darkest depths of the API.
I’m guessing it has something to do with the fact that they once had to waste time themselves, and they don’t want others to get off easy. Either that, or something about maintaining the status-quo as it’s benefacting the size of their e-penis which is directly proportional to their technological superiority.
Sorry, I let myself go a bit. This is the difference between a friendly project (like
socket.io
andnode.js
andLinux Mint
) and a hostile project (likeFilezilla
andDebian
), and I just hate to see promising projects be hostile. I don’t understand what drives people to go there.Anyway,
pako
itself is very sweet and powerful, so let me give my fellow devvers some friendly pointers on it’s usage, so they don’t have to spend half a day:Newbie-mistakes
pako
needs anuInt8
array. They might seem the same as normalArray
orArrayBuffer
from other frameworks oruInt16Array
JavaScript uses internally orString[]
, because they are all the same numbers, but it’s not the same.uInt8
array server side, because when sent over it’s just an Array. Convert it back touInt8
client-side.Example
As a friendly example for people who come across
pako
and - like me - aren’t uptodate on the assumptions and limitations ofUint8Array
(the docs and examples and API are useless in that regard - that’s why I recommended something like this in the first place), let me underline that the uInt bytearray needs to be constructed from an array. Not a string, not a bytestring. Here’s a little working example to get you started.Consider your server sends you a bytearray for a gzipped string. Here’s how to decompress:
Sending arrays from the server isn’t optimal. Of course,
Accept-Encoding
may tackle this by gzipping the array, but gzipping an array representation of a gzipped string isn’t the sweetest thing anyway. Better have the server send base64 encoded binary data.From here you can work with the API docs.
I hope this will bring some friendly and accessibility back to
pako
because it’s obviously an awesome library. 😸PS - Converting your data to an uint8 array in node using
new Uint8Array(bson).buffer;
before sending it over to the client, will freeze your Chromium browser tab when you executepako.deflate(data);
. Don’t know what’s going on, but it feels like something should be thrown in stead.@creationix thanks for the nice reply.
As I understand it,
pako
doesn’t really want to be affiliated with the type of usage I employ it for, nor is the team particularly interested in a more basic/novice addition to its documentation.I am inclined not to waste anyone else’s time on this, including my own. 😄