aboutsummaryrefslogtreecommitdiff
path: root/node_modules/crc32-stream/lib
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-10-10 03:43:44 +0200
committerFlorian Dold <florian.dold@gmail.com>2016-10-10 03:43:44 +0200
commitabd94a7f5a50f43c797a11b53549ae48fff667c3 (patch)
treeab8ed457f65cdd72e13e0571d2975729428f1551 /node_modules/crc32-stream/lib
parenta0247c6a3fd6a09a41a7e35a3441324c4dcb58be (diff)
downloadwallet-core-abd94a7f5a50f43c797a11b53549ae48fff667c3.tar.xz
add node_modules to address #4364
Diffstat (limited to 'node_modules/crc32-stream/lib')
-rw-r--r--node_modules/crc32-stream/lib/crc32-stream.js42
-rw-r--r--node_modules/crc32-stream/lib/deflate-crc32-stream.js67
-rw-r--r--node_modules/crc32-stream/lib/index.js10
3 files changed, 119 insertions, 0 deletions
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
diff --git a/node_modules/crc32-stream/lib/deflate-crc32-stream.js b/node_modules/crc32-stream/lib/deflate-crc32-stream.js
new file mode 100644
index 000000000..944eb0d0a
--- /dev/null
+++ b/node_modules/crc32-stream/lib/deflate-crc32-stream.js
@@ -0,0 +1,67 @@
+/**
+ * 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 zlib = require('zlib');
+var inherits = require('util').inherits;
+
+var crc32 = require('buffer-crc32');
+
+var DeflateCRC32Stream = module.exports = function (options) {
+ zlib.DeflateRaw.call(this, options);
+
+ this.checksum = new Buffer(4);
+ this.checksum.writeInt32BE(0, 0);
+
+ this.rawSize = 0;
+ this.compressedSize = 0;
+
+ // BC v0.8
+ if (typeof zlib.DeflateRaw.prototype.push !== 'function') {
+ this.on('data', function(chunk) {
+ if (chunk) {
+ this.compressedSize += chunk.length;
+ }
+ });
+ }
+};
+
+inherits(DeflateCRC32Stream, zlib.DeflateRaw);
+
+DeflateCRC32Stream.prototype.push = function(chunk, encoding) {
+ if (chunk) {
+ this.compressedSize += chunk.length;
+ }
+
+ return zlib.DeflateRaw.prototype.push.call(this, chunk, encoding);
+};
+
+DeflateCRC32Stream.prototype.write = function(chunk, enc, cb) {
+ if (chunk) {
+ this.checksum = crc32(chunk, this.checksum);
+ this.rawSize += chunk.length;
+ }
+
+ return zlib.DeflateRaw.prototype.write.call(this, chunk, enc, cb);
+};
+
+DeflateCRC32Stream.prototype.digest = function() {
+ return crc32.unsigned(0, this.checksum);
+};
+
+DeflateCRC32Stream.prototype.hex = function() {
+ return this.digest().toString(16).toUpperCase();
+};
+
+DeflateCRC32Stream.prototype.size = function(compressed) {
+ compressed = compressed || false;
+
+ if (compressed) {
+ return this.compressedSize;
+ } else {
+ return this.rawSize;
+ }
+}; \ No newline at end of file
diff --git a/node_modules/crc32-stream/lib/index.js b/node_modules/crc32-stream/lib/index.js
new file mode 100644
index 000000000..31187e38e
--- /dev/null
+++ b/node_modules/crc32-stream/lib/index.js
@@ -0,0 +1,10 @@
+/**
+ * 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
+ */
+exports = module.exports = require('./crc32-stream');
+exports.CRC32Stream = exports;
+exports.DeflateCRC32Stream = require('./deflate-crc32-stream'); \ No newline at end of file