Sha256: 269fa4b138190e68d25d70a64f51ff17c773cf13c5a155e58016c64131a41faa

Contents?: true

Size: 731 Bytes

Versions: 62

Compression:

Stored size: 731 Bytes

Contents

'use strict'

var zlib = require('zlib');

exports.async = true;

exports.run = function(data, level, callback) {
  //zlib.deflate(new Buffer(data), callback);

  var zlibStream = zlib.createDeflate({
    /*chunkSize: 128*1024,*/
    level: level
  });
  var buffers = [], nread = 0;


  zlibStream.on('error', function(err) {
    zlibStream.removeAllListeners();
    zlibStream=null;
    callback(err);
  });

  zlibStream.on('data', function(chunk) {
    buffers.push(chunk);
    nread += chunk.length;
  });

  zlibStream.on('end', function() {
    zlibStream.removeAllListeners();
    zlibStream=null;

    var buffer = Buffer.concat(buffers);

    callback(null);
  });

  zlibStream.write(data.buffer);
  zlibStream.end();
}

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
smock-0.1.268 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/benchmark/implementations/deflate-zlib/index.js
smock-0.1.267 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/benchmark/implementations/deflate-zlib/index.js
smock-0.1.266 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/benchmark/implementations/deflate-zlib/index.js
smock-0.1.265 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/benchmark/implementations/deflate-zlib/index.js
smock-0.1.264 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/benchmark/implementations/deflate-zlib/index.js
smock-0.1.263 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/benchmark/implementations/deflate-zlib/index.js
smock-0.1.262 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/benchmark/implementations/deflate-zlib/index.js
smock-0.1.261 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/benchmark/implementations/deflate-zlib/index.js
smock-0.1.260 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/benchmark/implementations/deflate-zlib/index.js
smock-0.1.259 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/benchmark/implementations/deflate-zlib/index.js
smock-0.1.258 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/benchmark/implementations/deflate-zlib/index.js
smock-0.1.256 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/benchmark/implementations/deflate-zlib/index.js
smock-0.1.255 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/benchmark/implementations/deflate-zlib/index.js
smock-0.1.254 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/benchmark/implementations/deflate-zlib/index.js
smock-0.1.253 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/benchmark/implementations/deflate-zlib/index.js
smock-0.1.252 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/benchmark/implementations/deflate-zlib/index.js
smock-0.1.251 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/benchmark/implementations/deflate-zlib/index.js
smock-0.1.250 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/benchmark/implementations/deflate-zlib/index.js
smock-0.1.249 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/benchmark/implementations/deflate-zlib/index.js
smock-0.1.247 node_modules/webpack/node_modules/node-libs-browser/node_modules/browserify-zlib/node_modules/pako/benchmark/implementations/deflate-zlib/index.js