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
0
votes
2 answers

How to unzip in PHP the data previously zipped in JavaScript

I'm trying to compress a JSON string with pako and send it to a PHP script (Laravel) and uncompress it, then modify it, compress again and sent it back to client. When I compress and uncompress in the client, it works perfect; but when I send…
jhon chacolla
  • 1,498
  • 1
  • 7
  • 7
0
votes
1 answer

Inflate response from websocket API

I am getting the following message from a websocket endpoint and would like to know how to inflate the message and get a json. The response is from a cryptocurrency websocket api. I generally use pako but am unable to get pako inflate the…
Sushanta Deb
  • 529
  • 8
  • 20
0
votes
1 answer

gzinflate string compressed via JS

I'm trying to compress a massive JS object on the client side via Pako and than get it back on the PHP-script. JS code const save_str = JSON.stringify(massive_object); const gz_str = pako.gzip(save_str, { to: 'string' }); $.post('/', …
Denis O.
  • 1,841
  • 19
  • 37
0
votes
0 answers

Compress data in AngularJS

I have this app, where the client has very low upload speed, so I need to compress the JSON they send to the server in order to improve their speed. I've checked several (probably all) questions on here about pako, gzip, zlib, etc... and can't get…
Steven
  • 1,236
  • 1
  • 13
  • 37
0
votes
1 answer

JQuery $.get and inflate data

I was handed over a small browser application which fetches a binary file, unpacks it and then shows it's content in the browser. I'm however not able to convert the data correctly into a byte array, and subsequently inflation fails with "invalid…
benjist
  • 2,740
  • 3
  • 31
  • 58
0
votes
0 answers

unzipping files over 2G in javascript

I have been using RawDeflate in my javascript code to unzip files. Recently I found that it was silently failing sometimes, and I traced it down to the case when the original file was over 2G. I tried switching to pako but that is also failing (at…
Larry Martell
  • 3,526
  • 6
  • 40
  • 76
0
votes
4 answers

using php-gzdeflate and pako-js

i am attempting to combine php-gzdeflate and pako. to compress the string i am using: const compressed = ' ' ; // compressed now contains: c87PLShKLS5WyE0FAA== but i cannot seem to read this…
edwardsmarkf
  • 1,387
  • 2
  • 16
  • 31
0
votes
1 answer

The difference between node.js ws permessagedeflate zlib decompression and that of pako?

I have a node.js ws websocket that receives compressed data. The docs are very shallow about the inflate mechanism but from reading through source files it is clearly in-built and should be activated automatically depending on the type of received…
Anonymous
  • 4,692
  • 8
  • 61
  • 91
-1
votes
1 answer

SyntaxError: Unexpected token '<' for Google Scripts

I have been using this same code in Google Apps Scripts for quite some time and I have started receiving the following error: SyntaxError: Unexpected token '<' This just started happening this week after many months of running the script. I can…
1 2 3
4