Questions tagged [pako]

Pako is a high speed zlib port to JavaScript. Pako is primarily built on nodeJS but can also be browserified and used in browsers as single source file eliminating the dependency of nodeJS.

About: Pako is a high speed zlib port to JavaScript. It is almost as fast in modern JS engines as C implementation. Pako is primarily built on nodeJS but can also be browserified and used in browsers as single source file eliminating the dependency of nodeJS.

It also provides chunking support for big blobs. Some of the famous projects that use pako are browserify (via browserify-zlib), JSZip, mincer, JS-Git and Tedit by @creatronix

Installation:

node.js: npm install pako

browser: bower install pako

Sample code:

var pako = require('pako');
var input = new Uint8Array();
// fill input data here
var output = pako.deflate(input);

var compressed = new Uint8Array();
// fill data to uncompress here
try {
   var result = pako.inflate(compressed);
} catch (err) {
   console.log(err);
}


var inflator = new pako.Inflate();
inflator.push(chunk1, false);
inflator.push(chunk2, false);
inflator.push(chunkN, true);
if (inflator.err) {
  console.log(inflator.msg);
}
var output = inflator.result;

Useful links:

Pako github repository

Issue Tracker

54 questions
7
votes
1 answer

Pako not able to deflate gzip files generated in python

I'm generating gzip files from python using the following code: (using python 3) file = gzip.open('output.json.gzip', 'wb') dataToWrite = json.dumps(data).encode('utf-8') file.write(dataToWrite) file.close() However, I'm trying to…
Ashwin Ramaswami
  • 873
  • 13
  • 22
5
votes
2 answers

Browser Javascript: Compress Json to gzip and upload to S3 presigned URL

Any advice would be appreciated. I've got a json variable in my web application that I'd like to gzip and upload to S3 through a presigned URL. I'm able to upload JSON successfully, but I fail to gzip the JSON and then upload it. The three separate…
Tielman Nieuwoudt
  • 903
  • 1
  • 12
  • 24
4
votes
2 answers

Reconstructing file/folder structure of a decompressed zip file in JS

I am trying to reconstruct the file/folder structure of a decompressed zip file in the browser with JavaScript. Ideally, I'd like to have all files in a FileList (as if they just got uploaded through a web page) or other iterable object. For…
Daniel Schreij
  • 773
  • 1
  • 10
  • 26
3
votes
1 answer

Client side decompression back to string from C# compression of string

I have some large data sets which I would like to compress before I send to my client. The compression works. Utilizing this bit of code which turns my data into a nice, small base64String: Example: string mytest = "This is some test text."; …
Frank M
  • 1,379
  • 9
  • 18
3
votes
1 answer

what is the right way to import a node module to angular typescript / angularcli

im importing some "legacy" (non typescript) js libs to my angular SPA. normally I just add a load from the cdn to index.html like: and in the angular-component i just…
mhoff
  • 601
  • 8
  • 13
3
votes
1 answer

Extracting gzip data in Javascript with Pako - encoding issues

I am trying to run what I expect is a very common use case: I need to download a gzip file (of complex JSON datasets) from Amazon S3, and decompress(gunzip) it in Javascript. I have everything working correctly except the final 'inflate' step. I am…
Keith Priddy
  • 103
  • 1
  • 8
2
votes
2 answers

I want to decompress a GZIP string with JavaScript

I have this GZIPed string: H4sIAAAAAAAA//NIzcnJVyguSUzOzi9LLUrLyS/XUSjJSMzLLlZIyy9SSMwpT6wsVshIzSnIzEtXBACs78K6LwAAAA== I created that with this website: http://www.txtwizard.net/compression I have tried using pako to ungzip it. import { ungzip }…
petur
  • 1,366
  • 3
  • 21
  • 42
2
votes
1 answer

Unable to inflate SessionStorage data; getting either 'incorrect header check' or 'invalid stored block lengths' depending on the inflation method

I have data exceeding 5MB I need to store in session storage. To that end, I'm using pako to compress the data. First, we have an Angular app that receives data from an API and adds it to a hash 'cachedLookups': const stringifiedLookups =…
Thomas Preston
  • 697
  • 1
  • 7
  • 19
2
votes
0 answers

How can I unzip file with JavaScript pako library in browser?

I'm making .glb viewer with a-frame. my glb file is big(around 400MB), so I'm trying to load compressed zip file (around 20MB) and decompressed it inside browser. However, pako is not working.. error log said "unknown compression method". I zipped a…
luvzqn
  • 21
  • 2
2
votes
1 answer

flutter/dart: How to decompress/inflate zlib binary string in flutter

I am using pako package on my nodejs server and sending compressed binary string from server to my flutter client. I am unable to decompress/inflate it on the flutter client. I have tried a combination of libraries My Server NodeJS Code: var…
Ramesh Guntha
  • 37
  • 1
  • 6
2
votes
1 answer

How to replicate GZipStream.Write() in JavaScript?

I have this piece of C# code: public static byte[] TestGzip(string text) { byte[] bytes = Encoding.UTF8.GetBytes(text); MemoryStream memoryStream1 = new MemoryStream(); using (GZipStream gzipStream = new…
user2263572
  • 35
  • 1
  • 9
2
votes
1 answer

I need JSZip and gzip for my web page, and JSZip has all the ingredients, but hides them in ways I can't crack

Support for gzip in JavaScript is surprisingly weak. All browsers implement it for supporting the Content-encoding: gzip header, but there is no standard access to the gzip / gunzip function of the browser. So one must use a javascript only…
Gunther Schadow
  • 1,490
  • 13
  • 22
2
votes
2 answers

Gzip a string in javascript using pako.js

I was able to decompress a string in JavaScript using pako.js http://jsfiddle.net/9yH7M/1/ // Get some base64 encoded binary data from the server. Imagine we got this: var b64Data =…
sireesha
  • 99
  • 1
  • 1
  • 6
2
votes
0 answers

Decompress byte array in node js

We currently have a project in android and company wants to do some parts on server. Server side code in with Node JS. The thing I want to do looks very simple but I am stuck on that. We have a long byte array which is compressed, in the android…
nfarshchi
  • 990
  • 1
  • 8
  • 25
1
vote
1 answer

Handling zlib compressed json data between C++ Qt and javascript using webchannel

I'd like to share my knowledge on this process since it does not seem to be trivial and had to spend some time to figure it out. Hope this will be a useful manual. The problem: There is a QT application, that sends large amount of data to be plot…
Peter Devenyi
  • 177
  • 2
  • 15
1
2 3 4