Comparing version 0.0.2 to 0.0.3
31
index.js
@@ -44,4 +44,3 @@ var EventEmitter = require('events').EventEmitter, | ||
options = extendObj(defaultOptions, options); | ||
this.options = options; | ||
this.options = extendObj(defaultOptions, options); | ||
@@ -89,9 +88,7 @@ this.stream = stream; | ||
self.buffer = Buffer.concat([self.buffer, chunk]); | ||
if (self.buffer.length >= self.options.bytes) { | ||
self.stream.pause(); | ||
self.flushChunk(function (e) { | ||
if (e) return self.emit('error', e); | ||
self.stream.resume(); | ||
}); | ||
} | ||
self.stream.pause(); | ||
self.flushChunk(function (e) { | ||
if (e) return self.emit('error', e); | ||
self.stream.resume(); | ||
}); | ||
} | ||
@@ -125,5 +122,5 @@ | ||
var newChunks = [], | ||
newChunk = {}; | ||
var newChunks = []; | ||
while (this.buffer.length >= this.options.bytes) { | ||
var newChunk = {}; | ||
if (this.buffer.length > this.options.bytes) { | ||
@@ -138,3 +135,5 @@ newChunk.data = this.buffer.slice(0, this.options.bytes); | ||
} | ||
newChunk.index = ++this.stats.chunks; | ||
console.log('Index: ', this.stats.chunks); | ||
newChunk.index = this.stats.chunks + 1; | ||
this.stats.chunks++; | ||
newChunks.push(newChunk); | ||
@@ -145,10 +144,14 @@ } | ||
if (!this.reading && last && this.buffer.length) { | ||
var newChunk = {}; | ||
newChunk.data = this.buffer.slice(0, this.options.bytes); | ||
this.buffer = this.buffer.slice(this.options.bytes); | ||
newChunk.index = ++this.stats.chunks; | ||
newChunk.index = this.stats.chunks + 1; | ||
this.stats.chunks + 1 | ||
newChunk.last = true; | ||
newChunks.push(newChunk); | ||
} | ||
async.eachSeries(newChunks, function (chunk, next) { | ||
console.log('chunk', chunk.data); | ||
if (!chunk) return next(); | ||
self.cb && self.cb(null, chunk); | ||
@@ -155,0 +158,0 @@ self.emit('chunk', chunk); |
@@ -9,3 +9,3 @@ { | ||
"description": "A simple and lightweight interface for chunking stream data in NodeJS", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"keywords": [ | ||
@@ -32,4 +32,4 @@ "chunk stream", | ||
"dependencies": { | ||
"async": "0.2.10" | ||
"async": "0.6.2" | ||
} | ||
} |
@@ -91,2 +91,3 @@ # Chunk It | ||
* v0.0.3 (2014-04-03) -- Fixed a critical issue. | ||
* v0.0.2 (2014-04-03) -- Added new examples and features. | ||
@@ -93,0 +94,0 @@ * v0.0.1 (2014-04-03) -- Initial release. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9715
131
118
+ Addedasync@0.6.2(transitive)
- Removedasync@0.2.10(transitive)
Updatedasync@0.6.2