How to use the minizlib.Gunzip function in minizlib

To help you get started, we’ve selected a few minizlib 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 npm / node-tar / test / pack.js View on Github external
gname: '',
        devmaj: 0,
        devmin: 0,
        atime: null,
        ctime: null,
        nullBlock: false
      }
      t.match(h, expect)
      t.equal(data.length, 2048)
      t.match(data.slice(1024).toString(), /^\0{1024}$/)

      const syncgz = new PackSync({ cwd: files, portable: true, gzip: true })
        .add('dir').end().read()

      t.equal(syncgz[9], 255, 'gzip OS flag set to "unknown"')
      const sync = new miniz.Gunzip().end(zipped).read()

      t.equal(sync.slice(512).toString(), data.slice(512).toString())
      const hs = new Header(sync)
      t.match(hs, expect)

      const expect2 = {
        type: 'File',
        cksumValid: true,
        needPax: false,
        path: 'dir/x',
        mode: 0o644,
        size: 0,
        mtime: mtime,
        cksum: Number,
        linkpath: '',
        uname: '',
github qddjs / qdd / lib / tar.js View on Github external
module.exports = function tar (cacheDir, destDir) {
  debug(() => `untar ${cacheDir} ${destDir}`);
  const gunzip = new zlib.Gunzip();
  const extractStream = tarStream.extract();
  extractStream.on('entry', (header, stream, next) => {
    if (header.type !== 'file') {
      stream.resume();
      stream.on('end', next);
      return;
    }
    const name = header.name.slice(header.name.indexOf('/'));
    if (!cacheDir) {
      writeOne(destDir + name, stream, next);
      return;
    }
    if (!destDir) {
      writeOne(cacheDir + name, stream, next);
      return;
    }
github standard-things / esm / src / fs / gunzip.js View on Github external
function fastPathGunzip(bufferOrString, options) {
  const stream = new Gunzip(options)

  if (options.encoding === "utf8") {
    let result = ""
    stream.on("data", (chunk) => result += chunk).end(bufferOrString)
    return result
  }

  return streamToBuffer(stream, bufferOrString)
}
github standard-things / esm / src / fs.js View on Github external
static gunzip(bufferOrString, options) {
    options = typeof options === "string" ? { encoding: options } : options
    options = utils.createOptions(options)

    if (useGunzipFastPath) {
      try {
        const stream = new minizlib.Gunzip(options)
        if (options.encoding === "utf8") {
          let result = ""
          stream.on("data", (chunk) => result += chunk).end(bufferOrString)
          return result
        }
        return streamToBuffer(stream, bufferOrString)
      } catch (e) {
        useGunzipFastPath = false
      }
    }
    return fallbackGunzip(bufferOrString, options)
  }

minizlib

A small fast zlib stream built on [minipass](http://npm.im/minipass) and Node.js's zlib binding.

MIT
Latest version published 8 months ago

Package Health Score

76 / 100
Full package analysis