How to use pako

Comprehensive pako code examples:

How to use pako.gzip:

51
52
53
54
55
56
57
58
59
60
  if (!payload || typeof payload !== 'object') return false;
  const jsonStringPost = JSON.stringify(payload);
  if (jsonStringPost && jsonStringPost.length > 1024 && compress) {
    // eslint-disable-next-line no-param-reassign
    options.headers['Content-Encoding'] = 'gzip';
    return pako.gzip(jsonStringPost);
  }
  return false;
}

How to use pako.inflateRaw:

9
10
11
12
13
14
15
    return pako.deflateRaw(input, {
        level : compressionOptions.level || -1 // default compression
    });
};
exports.uncompress =  function(input) {
    return pako.inflateRaw(input);
};

How to use pako.deflateRaw:

4
5
6
7
8
9
10
11
12
13
14
exports.uncompressInputType = USE_TYPEDARRAY ? "uint8array" : "array";
exports.compressInputType = USE_TYPEDARRAY ? "uint8array" : "array";


exports.magic = "\x08\x00";
exports.compress = function(input, compressionOptions) {
    return pako.deflateRaw(input, {
        level : compressionOptions.level || -1 // default compression
    });
};
exports.uncompress =  function(input) {

How to use pako.Inflate:

5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
* ```javascript
* var pako = require('pako')
*   , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])
*   , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);
*
* var inflate = new pako.Inflate({ level: 3});
*
* inflate.push(chunk1, false);
* inflate.push(chunk2, true);  // true -> last chunk
*

How to use pako.deflate:

5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
*
* ##### Example:
*
* ```javascript
* var pako = require('pako')
*   , input = pako.deflate([1,2,3,4,5,6,7,8,9])
*   , output;
*
* try {
*   output = pako.inflate(input);

How to use pako.Deflate:

398
399
400
401
402
403
404
405
406
407
* ```javascript
* var pako = require('pako')
*   , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])
*   , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);
*
* var deflate = new pako.Deflate({ level: 3});
*
* deflate.push(chunk1, false);
* deflate.push(chunk2, true);  // true -> last chunk
*

How to use pako.inflate:

216
217
218
219
220
221
222
223
224
225
},{}],4:[function(require,module,exports){
var pako = require('pako');
var atob = require('atob');

window.inflate = function(data) {
    return pako.inflate(data,  {"to": "string"})
}

window.base64 = function(base_data) {
                var data = atob(base_data);