streaming-cache
Advanced tools
Comparing version 0.3.0 to 0.3.1
22
index.js
@@ -171,3 +171,10 @@ 'use strict'; | ||
stream._read = function () { | ||
this.push(chunks.shift()); | ||
var chunk = chunks.shift(); | ||
if(!chunk){ | ||
this.needRead = true; | ||
} | ||
else{ | ||
this.push(chunk); | ||
this.needRead = false; | ||
} | ||
} | ||
@@ -177,3 +184,9 @@ stream._write = function (chunk, encoding, next) { | ||
emitters[key].emit('data', chunk); | ||
chunks.push(chunk); | ||
if(this.needRead){ | ||
this.push(chunk); | ||
} | ||
else{ | ||
chunks.push(chunk); | ||
} | ||
next(null, chunk); | ||
@@ -192,3 +205,8 @@ } | ||
stream.on('finish', function () { | ||
if(this.needRead){ | ||
this.push(null); | ||
} | ||
else{ | ||
chunks.push(null); | ||
} | ||
var c = self.cache.get(key); | ||
@@ -195,0 +213,0 @@ |
{ | ||
"name": "streaming-cache", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Cache and replay NodeJS streams", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
307950
517