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
1 answer

Sending large Data Object from Rails Backend to JavaScript Frontend with zlib

I am reviewing code I wrote a few years ago and stumbled across the following snippets that I use to send large data objects from my Ruby on Rails backend to the JavaScript frontend. I apply the zlib gem to compress and the pako library to…
wojja
  • 175
  • 1
  • 11
0
votes
1 answer

Decompress a GZIP CSV file on client side with Pako.js

Problem I want to load a large gzipped CSV file using the Fetch API and Pako.js with client-side code. This is the code I was using: const res = await fetch('www.example.com/large.csv.gzip'); let raw = await res.text(); raw =…
Madhav Malhotra
  • 385
  • 1
  • 5
  • 17
0
votes
1 answer

How to gzip a directory/folder using pako module in Nodejs?

I am trying to gzip my folder with the help of Pako library. I couldn't found any related content about it. Can someone explain me how to use pako to gzip directory. I am using it in my lambda function along with EFS. let bundle =…
Rehan CH
  • 109
  • 1
  • 11
0
votes
1 answer

JWS sign in java and typescript not producing the same result

I am trying to raw deflate the JSON string in Java using Deflater.class. But there is some difference between the deflated results generated by java and typescript. let bodyString = JSON.stringify(idTokenPayload); const fields = deflate ? { zip:…
user1700138
  • 35
  • 2
  • 7
0
votes
1 answer

Inflating partial gzip content with pako?

In node, zlib can be used to decompress partial gzip content (truncated). I tried the same with pako, but looks like it's not working. This is what I tried: const s =…
Moshe Shaham
  • 15,448
  • 22
  • 74
  • 114
0
votes
0 answers

How to zlib deflate a string in browser

I have in my backend a simple system for encrypting and compressing data. Backend NodeJS export const aesEncrypt = (text: string, key: string = ENCRYPTION_KEY) => { let iv = randomBytes(IV_LENGTH); let cipher = createCipheriv('aes-256-cbc',…
Mederic
  • 1,949
  • 4
  • 19
  • 36
0
votes
1 answer

Gzip compression - different output for the same input using python gzip and js pako

I've run into a bit of an issue with gzip compression. Say we compress the letter 'a' with pako library in javascript, as follows: pako.gzip('a') This returns the following byte array: [31,139,8,0,0,0,0,0,0,3,75,4,0,67,190,183,232,1,0,0,0] Now, if…
itsk
  • 9
  • 1
0
votes
1 answer

node pako.gizp() with python gzip issue

I was restoring the Node pako gzip method using Python and encountered the following problem: node: const pako = require('pako'); const test = 'aaa' var data = pako.gzip(test); console.log(data) Uint8Array(23) [ 31, 139, 8, 0, 0, 0, 0, 0, …
0
votes
0 answers

Decompress JSON data in Javascript

The R rgl package exports an HTML widget with the rglwidget() function, built using the htmlwidgets package. Often the data for this widget is quite large, and Pandoc and webshot2 choke on it. I would like to try compressing the data when the HTML…
user2554330
  • 37,248
  • 4
  • 43
  • 90
0
votes
1 answer

In a Session Storage key value pair, is there a character limit to the length of the value string?

I have an object whose data exceeds 5MB. I'm using pako to compress the data down to about 1.7MB. I then try to store that compressed data into session storage. For smaller objects this works fine, but for this larger object I exceed the quota. …
Thomas Preston
  • 697
  • 1
  • 7
  • 19
0
votes
2 answers

Implementation encryption and decryption OpenSSL and zlib in reactJS

I've PHP code that have 2 functions there are encryption and decryption that using openSSL, actually before I refactored it, I encoded the openSSL result to base64, cause it too long I change to compress using zlib (gzdeflate, gzinflate) then…
0x00b0
  • 343
  • 1
  • 3
  • 17
0
votes
1 answer

Deflating a response in Rails & inflating in JS

I have created an API in Ruby on Rails. Rather than sending the response body back with the API response, I am broadcasting it to an external service, which then takes care of the realtime distribution to all connected clients (i.e.…
HermannHH
  • 1,732
  • 1
  • 27
  • 57
0
votes
0 answers

Decompress numpy array in JS

I have Numpy Array of floats which I compress using zlib and store in database. Then I want to send compressed data over HTTP and decompress on client side using JavaScript. How can I do it? I am compressing data using below code: import numpy as…
Michael280
  • 48
  • 10
0
votes
1 answer

how to decompress data in php and the data which use pako.deflate from js

I use pako.deflate to compress data in javascript, like this: js file: const params = [{id: 5, name: '张三', list: [{code: '10010', type: 'media'}]},{id: 6, name: '李四', list: [{code: '20010', type: 'site'}]}] let binaryString =…
serenas
  • 137
  • 4
  • 10
0
votes
1 answer

pako.deflate not reducing the size of my request

I have a POST request that has a large payload. I'm trying to deflate it with pako before making the request to the server so it is smaller. However my payload sizes are no different for the compressed version than the uncompressed. Am I missing…
Abby
  • 3,169
  • 1
  • 21
  • 40