var zlib = require('zlib');
var inherits = require('util').inherits;

var util = require('./');

function DeflateRawChecksum(options) {
  zlib.DeflateRaw.call(this, options);

  this.checksum = util.crc32.createCRC32();
  this.digest = null;

  this.rawSize = 0;
  this.compressedSize = 0;

  this.on('data', function(chunk) {
    this.compressedSize += chunk.length;
  });

  this.on('end', function() {
    this.digest = this.checksum.digest();
  });
}

inherits(DeflateRawChecksum, zlib.DeflateRaw);

DeflateRawChecksum.prototype._transform = function(chunk, encoding, callback) {
  if (chunk) {
    this.checksum.update(chunk);
    this.rawSize += chunk.length;
  }

  return zlib.DeflateRaw.prototype._transform.call(this, chunk, encoding, callback);
};

module.exports = DeflateRawChecksum;

var zlib = require('zlib');
var inherits = require('util').inherits;

var util = require('./');

function DeflateRawChecksum(options) {
  zlib.DeflateRaw.call(this, options);

  this.checksum = util.crc32.createCRC32();
  this.digest = null;

  this.rawSize = 0;
  this.compressedSize = 0;

  this.on('data', function(chunk) {
    this.compressedSize += chunk.length;
  });

  this.on('end', function() {
    this.digest = this.checksum.digest();
  });
}

inherits(DeflateRawChecksum, zlib.DeflateRaw);

DeflateRawChecksum.prototype.write = function(chunk, cb) {
  if (chunk) {
    this.checksum.update(chunk);
    this.rawSize += chunk.length;
  }

  return zlib.DeflateRaw.prototype.write.call(this, chunk, cb);
};

module.exports = DeflateRawChecksum;

Revert "util: make DeflateRaw Checksum hook into _transform so that it mimicks the norms."
Revert "util: make DeflateRaw Checksum hook into _transform so that it mimicks the norms."

This reverts commit cf22d920b48c3c320b0a7a75577b082901db07a6.
