Crc32Probe.js 599 B

123456789101112131415161718192021222324
  1. "use strict";
  2. var GenericWorker = require("./GenericWorker");
  3. var crc32 = require("../crc32");
  4. var utils = require("../utils");
  5. /**
  6. * A worker which calculate the crc32 of the data flowing through.
  7. * @constructor
  8. */
  9. function Crc32Probe() {
  10. GenericWorker.call(this, "Crc32Probe");
  11. this.withStreamInfo("crc32", 0);
  12. }
  13. utils.inherits(Crc32Probe, GenericWorker);
  14. /**
  15. * @see GenericWorker.processChunk
  16. */
  17. Crc32Probe.prototype.processChunk = function (chunk) {
  18. this.streamInfo.crc32 = crc32(chunk.data, this.streamInfo.crc32 || 0);
  19. this.push(chunk);
  20. };
  21. module.exports = Crc32Probe;