How to use the pako.inflateRaw function in pako

To help you get started, we’ve selected a few pako examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github algenty / grafana-flowcharting / dist / utils.js View on Github external
}
    } catch (e) {// ignore
    }

    if (base64) {
      try {
        data = atob(data);
      } catch (e) {
        console.error(e);
        return;
      }
    }

    if (deflate && data.length > 0) {
      try {
        data = this.bytesToString(pako.inflateRaw(data));
      } catch (e) {
        console.error(e);
        return;
      }
    }

    if (encode) {
      try {
        data = decodeURIComponent(data);
      } catch (e) {
        console.error(e);
        return;
      }
    }

    return data;
github ukyo / zlib-wasm-without-emscripten-sample / benchmark / bench-1mbtxt.js View on Github external
})
    .add('native', {
      fn: () => zlib.deflateRawSync(source, { chunkSize, level }),
    })
    .on('cycle', (event) => {
      console.log(String(event.target));
    })
    .on('complete', () => {
      console.log('Deflate: Fastest is ' + suiteDef.filter('fastest').map('name'));
    })
    .run();

  // warmup
  const deflated = zlib.deflateRawSync(source, { level: 6 });
  myZlib.inflate(deflated);
  pako.inflateRaw(deflated, { chunkSize });
  zlib.inflateRawSync(deflated, { chunkSize });

  console.log(`## deflated lorem_1mb.txt size: ${deflated.length}`);

  const suiteInf = new Benchmark.Suite("inflate");

  suiteInf
    .add('wasm', {
      fn: () => myZlib.inflate(deflated),
    })
    .add('pako', {
      fn: () => pako.inflateRaw(deflated, { chunkSize }),
    })
    .add('native', {
      fn: () => zlib.inflateRawSync(deflated, { chunkSize }),
    })
github calebegg / codewich / src / urls.ts View on Github external
htmlSource: '',
}): WichData {
  const [version, ...data] = fragment.split(',');
  switch (version) {
    case '':  // Starting fresh
      return defaults;
    case 'v1':
      // Code is always last in the URL, to allow for more values below.
      const code = data.pop()!;
      const [maybeViewType, maybeStrictLevel] = data;
      const viewType = Number(maybeViewType || 0) as ViewType;
      const strictLevel = Number(maybeStrictLevel || 0) as StrictLevel;

      let inflated;
      if (code) {
        inflated = inflateRaw(
            atob(code.replace(/\./g, '+').replace(/_/g, '/')), {to: 'string'});
      } else {
        inflated = '\0\0';
      }
      const [scriptSource, cssSource, htmlSource] = inflated.split('\0');
      return {viewType, strictLevel, scriptSource, cssSource, htmlSource};
    default:
      throw new Error(`Unexpected version ${version}`);
  }
}
github MitchTalmadge / Emoji-Tools-Rewritten / src / scripts / core / services / cgbi.service.ts View on Github external
combinedIDATChunk.data = Buffer.concat([combinedIDATChunk.data, chunk.data]);

                                // Check if this is the first IDAT Chunk encountered.
                                if (!seenFirstIDAT) {
                                    // Since it is the first, put the new IDAT here after removing this Chunk.
                                    array.splice(index, 1, combinedIDATChunk);
                                    seenFirstIDAT = true;
                                } else {
                                    // Not the first, so just remove this Chunk.
                                    array.splice(index, 1);
                                }
                            }
                        });

                        // Inflate (Uncompress) IDAT Chunk
                        let rawData = pako.inflateRaw(new Uint8Array(combinedIDATChunk.data));

                        // Swap pixels in combined IDAT Chunk. (CgBI -> RGBA)
                        let i = 0;
                        for (let y = 0; y < details.height; y++) {
                            // Read one byte to skip over the filter type byte.
                            i++;
                            for (let x = 0; x < details.width; x++) {
                                // Swap pixels 0 and 2.
                                let temp = rawData[i];
                                rawData[i] = rawData[i + 2];
                                rawData[i + 2] = temp;

                                // 4 Bytes per x value.
                                i += 4;
                            }
                        }
github algenty / grafana-flowcharting / src / utils.js View on Github external
const diagrams = node.getElementsByTagName('diagram');

        if (diagrams.length > 0) {
          data = this.getTextContent(diagrams[0]);
        }
      }
    } catch (e) {
      // ignore
    }

    if (base64) {
        data = atob(data);
    }

    if (deflate && data.length > 0) {
        data = this.bytesToString(pako.inflateRaw(data));
    }

    if (encode) {
        data = decodeURIComponent(data);
    }

    return data;
  },
github Litarvan / pronote-api / src / cipher.js View on Github external
string = string.slice(32);*/

    let key = forge.md.md5.create().update(rsaKey.bytes()).digest();
    let iv = session.ivAES.length() ? forge.md.md5.create().update(session.ivAES.bytes()).digest() : new forge.util.ByteBuffer();

    let cipher = forge.cipher.createDecipher('AES-CBC', key);
    cipher.start({
        iv: iv
    });
    cipher.update(new forge.util.ByteBuffer(forge.util.hexToBytes(string)));

    let result = cipher.finish() && cipher.output.bytes();

    if (compress && !session.disableCompress)
    {
        result = pako.inflateRaw(result, {
            to: 'string'
        })
    }

    /*let toCompare = forge.md.md5.create().update(result).update(rsaKey.bytes()).digest().toHex().toUpperCase();

    if (md5 !== toCompare)
    {
        console.error(`MD5 DOESN'T MATCH : ${md5} != ${toCompare}`);
        throw new Error('Bad response');
    }*/

    result = forge.util.decodeUtf8(result);

    if (alea)
    {
github bmeck / noda-loader / lib / zip.js View on Github external
inflateRawSync = function (buf) {
    return new Buffer(new Uint8Array(pako.inflateRaw(buf)));
  }
}