event-stream
Advanced tools
Comparing version 0.8.2 to 0.9.0
34
index.js
@@ -32,3 +32,35 @@ //filter will reemit the data if cb(err,pass) pass is truthy | ||
// buffered | ||
// | ||
// same as a through stream, but won't emit a chunk until the next tick. | ||
// does not support any pausing. intended for testing purposes. | ||
es.asyncThrough = function () { | ||
var stream = new Stream() | ||
var queue = [] | ||
var ended = false | ||
bLen = bLen == null ? -1 : bLen //default to -1, infinite buffer. | ||
stream.readable = stream.writable = true | ||
stream.flush = function () { | ||
while(queue.length) | ||
stream.emit('data', queue.shift()) | ||
if(ended) stream.emit('end') | ||
} | ||
stream.write = function (data) { | ||
if(ended) return | ||
if(!queue.length) | ||
process.nextTick(stream.flush) | ||
queue.push(data) | ||
return true | ||
} | ||
stream.end = function (data) { | ||
if(data) stream.write(data) | ||
ended = true | ||
if(!queue.length) | ||
stream.emit('end') | ||
} | ||
return stream | ||
} | ||
// writable stream, collects all events into an array | ||
@@ -158,2 +190,3 @@ // and calls back when 'end' occurs | ||
, inNext = false | ||
//pipe only allows one argument. so, do not | ||
function next (err) { | ||
@@ -168,3 +201,2 @@ inNext = true | ||
args.shift() //drop err | ||
if (args.length){ | ||
@@ -171,0 +203,0 @@ args.unshift('data') |
{ "name": "event-stream" | ||
, "version": "0.8.2" | ||
, "version": "0.9.0" | ||
, "description": "construct pipes of streams of events" | ||
@@ -4,0 +4,0 @@ , "homepage": "http://github.com/dominictarr/event-stream" |
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
41005
1054