diff options
Diffstat (limited to 'node_modules/crc32-stream')
-rw-r--r-- | node_modules/crc32-stream/LICENSE | 22 | ||||
-rw-r--r-- | node_modules/crc32-stream/README.md | 81 | ||||
-rw-r--r-- | node_modules/crc32-stream/lib/crc32-stream.js | 42 | ||||
-rw-r--r-- | node_modules/crc32-stream/lib/deflate-crc32-stream.js | 67 | ||||
-rw-r--r-- | node_modules/crc32-stream/lib/index.js | 10 | ||||
-rw-r--r-- | node_modules/crc32-stream/package.json | 45 |
6 files changed, 267 insertions, 0 deletions
diff --git a/node_modules/crc32-stream/LICENSE b/node_modules/crc32-stream/LICENSE new file mode 100644 index 000000000..819b403f0 --- /dev/null +++ b/node_modules/crc32-stream/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2014 Chris Talkington, contributors.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file diff --git a/node_modules/crc32-stream/README.md b/node_modules/crc32-stream/README.md new file mode 100644 index 000000000..040bdef07 --- /dev/null +++ b/node_modules/crc32-stream/README.md @@ -0,0 +1,81 @@ +# crc32-stream v1.0.0 [](https://travis-ci.org/archiverjs/node-crc32-stream) [](https://ci.appveyor.com/project/ctalkington/node-crc32-stream/branch/master)
+
+crc32-stream is a streaming CRC32 checksumer. It uses [buffer-crc32](https://www.npmjs.org/package/buffer-crc32) behind the scenes to reliably handle binary data and fancy character sets. Data is passed through untouched.
+
+[](https://nodei.co/npm/crc32-stream/)
+
+### Install
+
+```bash
+npm install crc32-stream --save
+```
+
+You can also use `npm install https://github.com/archiverjs/node-crc32-stream/archive/master.tar.gz` to test upcoming versions.
+
+### Usage
+
+#### CRC32Stream
+
+Inherits [Transform Stream](http://nodejs.org/api/stream.html#stream_class_stream_transform) options and methods.
+
+```js
+var CRC32Stream = require('crc32-stream');
+
+var source = fs.createReadStream('file.txt');
+var checksum = new CRC32Stream();
+
+checksum.on('end', function(err) {
+ // do something with checksum.digest() here
+});
+
+// either pipe it
+source.pipe(checksum);
+
+// or write it
+checksum.write('string');
+checksum.end();
+```
+
+#### DeflateCRC32Stream
+
+Inherits [zlib.DeflateRaw](http://nodejs.org/api/zlib.html#zlib_class_zlib_deflateraw) options and methods.
+
+```js
+var DeflateCRC32Stream = require('crc32-stream').DeflateCRC32Stream;
+
+var source = fs.createReadStream('file.txt');
+var checksum = new DeflateCRC32Stream();
+
+checksum.on('end', function(err) {
+ // do something with checksum.digest() here
+});
+
+// either pipe it
+source.pipe(checksum);
+
+// or write it
+checksum.write('string');
+checksum.end();
+```
+
+### Instance API
+
+#### digest()
+
+Returns the checksum digest in unsigned form.
+
+#### hex()
+
+Returns the hexadecimal representation of the checksum digest. (ie E81722F0)
+
+#### size(compressed)
+
+Returns the raw size/length of passed-through data.
+
+If `compressed` is `true`, it returns compressed length instead. (DeflateCRC32Stream)
+
+## Things of Interest
+
+- [Changelog](https://github.com/archiverjs/node-crc32-stream/releases)
+- [Contributing](https://github.com/archiverjs/node-crc32-stream/blob/master/CONTRIBUTING.md)
+- [MIT License](https://github.com/archiverjs/node-crc32-stream/blob/master/LICENSE-MIT)
\ No newline at end of file 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 diff --git a/node_modules/crc32-stream/package.json b/node_modules/crc32-stream/package.json new file mode 100644 index 000000000..e27b06964 --- /dev/null +++ b/node_modules/crc32-stream/package.json @@ -0,0 +1,45 @@ +{
+ "name": "crc32-stream",
+ "version": "1.0.0",
+ "description": "a streaming CRC32 checksumer",
+ "homepage": "https://github.com/archiverjs/node-crc32-stream",
+ "author": {
+ "name": "Chris Talkington",
+ "url": "http://christalkington.com/"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/archiverjs/node-crc32-stream.git"
+ },
+ "bugs": {
+ "url": "https://github.com/archiverjs/node-crc32-stream/issues"
+ },
+ "license": "MIT",
+ "main": "lib/index.js",
+ "files": [
+ "lib"
+ ],
+ "engines": {
+ "node": ">= 0.10.0"
+ },
+ "scripts": {
+ "test": "mocha --reporter dot"
+ },
+ "dependencies": {
+ "readable-stream": "^2.0.0",
+ "buffer-crc32": "^0.2.1"
+ },
+ "devDependencies": {
+ "chai": "^3.4.0",
+ "mocha": "^2.3.0"
+ },
+ "keywords": [
+ "crc32-stream",
+ "crc32",
+ "stream",
+ "checksum"
+ ],
+ "publishConfig": {
+ "registry": "https://registry.npmjs.org/"
+ }
+}
\ No newline at end of file |