How to use zlib - 10 common examples

To help you get started, we’ve selected a few zlib 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 alanhoff / node-tar.gz / index.js View on Github external
TarGz.prototype.createParseStream = function() {
  var stream1 = zlib.createGunzip(this._options.zlib);
  var stream2 = tar.Parse();

  this._bubble(stream1, stream2);

  // Capture the entry event
  stream2.on('entry', function(entry) {
    stream1.emit('entry', entry);
  });

  stream1.pipe(stream2);
  return stream1;
};
github N0taN3rd / node-warc / lib / writers / warcWriterBase.js View on Github external
return new Promise((resolve, reject) => {
      if (this.opts.gzip) {
        // we're in gzipped mode - GZip the buffer
        recordBuffer = zlib.gzipSync(recordBuffer)
      }

      if (!this._warcOutStream.write(recordBuffer, 'utf8')) {
        this._warcOutStream.once('drain', resolve)
      } else {
        resolve()
      }
    })
  }
github horpto / nodecap2 / test / stream_spec.js View on Github external
server.request('*', (icapReq, icapRes, req, res, next) => {
    icapRes.setIcapStatusCode(200);
    icapRes.setIcapHeaders(icapReq.headers);
    icapRes.setHttpMethod(req);
    icapRes.setHttpHeaders(req.headers);
    icapRes.writeHeaders(icapReq.hasBody());

    const unzipper = zlib.createUnzip();
    unzipper.pipe(icapRes);
    icapReq.pipe(unzipper);
  });
github facebook / react-360 / Examples / DashSample / downloadAssets.js View on Github external
var fs = require('fs');
var tar = require('tar-fs')
var request = require('request');
var zlib = require('zlib');

request('https://www.dropbox.com/s/4h5iuryd3myfha8/asset.tar.gz?dl=1')
  .pipe(zlib.createGunzip())
  .pipe(tar.extract('./static_assets'));
github angular / angular.js / i18n / ucd / src / extract.js View on Github external
function main() {
  extractValues(
    fs.createReadStream(__dirname + '/ucd.all.flat.xml.gz').pipe(zlib.createGunzip()),
    propertiesToExtract,
    writeFile);

  function writeFile(validRanges) {
    var code = generateCode(validRanges);
    try {
      fs.lstatSync(__dirname + '/../../../src/ngParseExt');
    } catch (e) {
      fs.mkdirSync(__dirname + '/../../../src/ngParseExt');
    }
    fs.writeFile(__dirname + '/../../../src/ngParseExt/ucd.js', code);
  }
}
github AuspeXeu / openvpn-status / utils.js View on Github external
req.on('response', resp => {
          if (resp.statusCode === 200)
            req.pipe(zlib.createGunzip()).pipe(fs.createWriteStream(ipFile))
              .on('finish', () => {
                loadFile(resolve)
              })
          else
            loadFile(resolve)
        })
      } else
github fergiemcdowall / search-index / lib / indexing / replicator.js View on Github external
replicator.replicateFromSnapShotStream = function (readStream, indexes, callback) {
    var indexesws = levelws(indexes);
    readStream.pipe(zlib.createGunzip())
      .pipe(JSONStream.parse())
      .pipe(indexesws.createWriteStream())
      .on('close', callback);
  };
github advanced-rest-client / arc-electron / scripts / renderer / socket-request.js View on Github external
return new Promise((resolve, reject) => {
      zlib.gunzip(body, (err, buffer) => {
        if (err) {
          reject(new Error(err.message || err));
        } else {
          resolve(buffer);
        }
      });
    });
  }
github Wizcorp / Jeff / src / CanvasRenderer / renderImageToCanvas.js View on Github external
function inflate(strdata, onData) {
	var data = new Buffer(strdata);
	zlib.inflate(data, function (error, buffer) {
		if (error) throw new Error('Invalid compressed data. ' + error);
		onData(buffer);
	});
};
github Deathspike / mangarack / lib / nodejs / request.js View on Github external
res.on('end', function() {
      var buffer = Buffer.concat(chunks);
      var compression = res.headers['content-encoding'];
      var callback = _createRequestCallback(address, encoding, done);
      var location = res.headers.location;
      if (location) return _request(location, encoding, done, n + 1 || 1);
      if (compression === 'gzip') {
        return zlib.gunzip(buffer, callback);
      } else if (compression === 'deflate') {
        return zlib.inflateRaw(buffer, callback);
      } else {
        callback(undefined, buffer);
      }
    });
  }).on('error', function(err) {

zlib

Simple, synchronous deflate/inflate for buffers

Unrecognized
Latest version published 13 years ago

Package Health Score

56 / 100
Full package analysis