From abd94a7f5a50f43c797a11b53549ae48fff667c3 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 10 Oct 2016 03:43:44 +0200 Subject: add node_modules to address #4364 --- node_modules/crc32-stream/lib/crc32-stream.js | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 node_modules/crc32-stream/lib/crc32-stream.js (limited to 'node_modules/crc32-stream/lib/crc32-stream.js') diff --git a/node_modules/crc32-stream/lib/crc32-stream.js b/node_modules/crc32-stream/lib/crc32-stream.js new file mode 100644 index 000000000..42cb45400 --- /dev/null +++ b/node_modules/crc32-stream/lib/crc32-stream.js @@ -0,0 +1,42 @@ +/** + * node-crc32-stream + * + * Copyright (c) 2014 Chris Talkington, contributors. + * Licensed under the MIT license. + * https://github.com/archiverjs/node-crc32-stream/blob/master/LICENSE-MIT + */ +var inherits = require('util').inherits; +var Transform = require('readable-stream').Transform; + +var crc32 = require('buffer-crc32'); + +var CRC32Stream = module.exports = function CRC32Stream(options) { + Transform.call(this, options); + this.checksum = new Buffer(4); + this.checksum.writeInt32BE(0, 0); + + this.rawSize = 0; +}; + +inherits(CRC32Stream, Transform); + +CRC32Stream.prototype._transform = function(chunk, encoding, callback) { + if (chunk) { + this.checksum = crc32(chunk, this.checksum); + this.rawSize += chunk.length; + } + + callback(null, chunk); +}; + +CRC32Stream.prototype.digest = function() { + return crc32.unsigned(0, this.checksum); +}; + +CRC32Stream.prototype.hex = function() { + return this.digest().toString(16).toUpperCase(); +}; + +CRC32Stream.prototype.size = function() { + return this.rawSize; +}; \ No newline at end of file -- cgit v1.2.3