How to use pako - 10 common examples

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 kubernetes / test-infra / prow / spyglass / lenses / coverage / coverage.ts View on Github external
window.onload = () => {
  // Because the coverage files are a) huge, and b) compress excellently, we send it as
  // gzipped base64. This is faster unless your internet connection is faster than
  // about 300 Mb/s.
  const content = inflate(atob(COVERAGE_FILE), {to: 'string'});
  const coverage = parseCoverage(content);
  document.getElementById('statement-coverage')!.innerText = `${(coverage.coveredStatements / coverage.totalStatements * 100).toFixed(0)}% (${coverage.coveredStatements.toLocaleString()} of ${coverage.totalStatements.toLocaleString()} statements)`;
  document.getElementById('file-coverage')!.innerText = `${(coverage.coveredFiles / coverage.totalFiles * 100).toFixed(0)}% (${coverage.coveredFiles.toLocaleString()} of ${coverage.totalFiles.toLocaleString()} files)`;
  renderChildren(document.getElementById('treemap')!, coverage, true);
};
github neuroanatomy / BrainBox / view / atlasMaker / src / atlasmaker-interaction.js View on Github external
reader.onload = function (e) {
                var result = e.target.result;
                var nii;
                if(name.name.split('.').pop() === "gz") {
                    var inflate = new pako.Inflate();
                    inflate.push(new Uint8Array(result), true);
                    nii = inflate.result.buffer;
                } else { nii = result; }
                var mri = me.loadNifti(nii);

                if( mri.dim[0] !== me.User.dim[0] ||
                    mri.dim[1] !== me.User.dim[1] ||
                    mri.dim[2] !== me.User.dim[2]) {
                    console.log("ERROR: Volume dimensions do not match");

                    return;
                }

                // copy uploaded data to atlas data
                var i;
                for(i = 0; i
github pd4d10 / npmview / src / app.js View on Github external
unzip = async () => {
    const res = await fetch(
      'https://cors-anywhere.herokuapp.com/https://registry.npmjs.org/tiza/download/tiza-2.1.0.tgz',
    )
    const data = await res.arrayBuffer()
    const buffer = await pako.ungzip(data)
    // console.log(buffer)
    untar(buffer.buffer).then(console.log, console.log, console.log)
    // console.log(t)
  }
github superfly / fly / packages / core / src / cmd / deploy.ts View on Github external
finish() {
                  log.debug("Finished packing.")
                  const buf = readFileSync(pathResolve(cwd, ".fly/bundle.tar"))
                  console.log(`Bundle size: ${buf.byteLength / (1024 * 1024)}MB`)
                  const gz = pako.gzip(buf)
                  console.log(`Bundle compressed size: ${gz.byteLength / (1024 * 1024)}MB`)
                  const bundleHash = createHash("sha1") // we need to verify the upload is :+1:
                  bundleHash.update(buf)

                  API.post(`/api/v1/apps/${appName}/releases`, gz, {
                    params: {
                      sha1: bundleHash.digest("hex"),
                      env
                    },
                    headers: {
                      "Content-Type": "application/x-tar",
                      "Content-Length": gz.byteLength,
                      "Content-Encoding": "gzip"
                    },
                    maxContentLength: 100 * 1024 * 1024,
                    timeout: 120 * 1000
github SamyPesse / gitkit-js / src / models / PackFile.js View on Github external
function parseInflateContent(parser: Dissolve): Dissolve {
    const inflator = new Inflate();

    // Iterate while we found end of zip content
    return parser.loop(end => {
        parser.buffer('byte', 1).tap(() => {
            const byte = parser.vars.byte;

            const ab = new Uint8Array(1);
            ab.fill(byte[0]);

            inflator.push(ab);

            if (inflator.ended) {
                if (inflator.err) {
                    parser.emit('error', new Error(inflator.msg));
                }
github SamyPesse / gitkit-js / lib / TransferUtils / parsePack.js View on Github external
function parseInflateContent(parser) {
    var inflator = new pako.Inflate();

    // Iterate while we found end of zip content
    return parser.loop(function(end) {
        this.buffer('byte', 1)
        .tap(function() {
            var byte = this.vars.byte;

            var ab = new Uint8Array(1);
            ab.fill(byte[0]);

            inflator.push(ab);

            if (inflator.ended) {
                if (inflator.err) {
                    this.emit('error', new Error(inflator.msg));
                }
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 zerobias / telegram-mtproto / packages / telegram-mtproto / src / bin.js View on Github external
export function gzipUncompress(bytes: Uint8Array): Uint8Array {
  // console.log('Gzip uncompress start')
  const result = inflate(bytes)
  // console.log('Gzip uncompress finish')
  return result
}