stream-buffers
Advanced tools
Comparing version 0.2.5 to 0.2.6
@@ -11,3 +11,3 @@ var stream = require("stream"), | ||
opts = opts || {}; | ||
var frequency = opts.frequency || constants.DEFAULT_FREQUENCY; | ||
var frequency = opts.hasOwnProperty("frequency") ? opts.frequency : constants.DEFAULT_FREQUENCY; | ||
var chunkSize = opts.chunkSize || constants.DEFAULT_CHUNK_SIZE; | ||
@@ -26,4 +26,4 @@ var initialSize = opts.initialSize || constants.DEFAULT_INITIAL_SIZE; | ||
if(!size) { | ||
that.emit("end"); | ||
return; | ||
that.emit("end"); | ||
return; | ||
} | ||
@@ -81,6 +81,13 @@ | ||
} | ||
if (!this.isPaused && !frequency) { | ||
while (size > 0) { | ||
sendData(); | ||
} | ||
} | ||
}; | ||
this.pause = function() { | ||
if(sendData) { | ||
this.isPaused = true; | ||
if(sendData && sendData.interval) { | ||
clearInterval(sendData.interval); | ||
@@ -92,3 +99,4 @@ delete sendData.interval; | ||
this.resume = function() { | ||
if(sendData && !sendData.interval) { | ||
this.isPaused = false; | ||
if(sendData && !sendData.interval && frequency > 0) { | ||
sendData.interval = setInterval(sendData, frequency); | ||
@@ -95,0 +103,0 @@ } |
{ | ||
"name": "stream-buffers", | ||
"version": "0.2.5", | ||
"description": "Buffer-backed Streams for reading and writing.", | ||
"keywords": "memory streams, buffer streams", | ||
"author": "Sam Day <sam.c.day@gmail.com>", | ||
"main": "./lib/streambuffer.js", | ||
"engines": { "node": ">= 0.3.0" }, | ||
"dependencies": { | ||
}, | ||
"devDependencies": { | ||
"vows": ">= 0.5.6" | ||
}, | ||
"repository" : { | ||
"type" : "git", | ||
"url" : "https://github.com/samcday/node-stream-buffer.git" | ||
}, | ||
"scripts": { | ||
"test": "vows --spec" | ||
} | ||
"name": "stream-buffers", | ||
"version": "0.2.6", | ||
"description": "Buffer-backed Streams for reading and writing.", | ||
"keywords": [ | ||
"memory streams", | ||
"streams", | ||
"buffer streams" | ||
], | ||
"author": "Sam Day <me@samcday.com.au>", | ||
"main": "./lib/streambuffer.js", | ||
"engines": { | ||
"node": ">= 0.3.0" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"vows": ">= 0.5.6" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/samcday/node-stream-buffer.git" | ||
}, | ||
"scripts": { | ||
"test": "vows --spec" | ||
}, | ||
"publishConfig": { | ||
"registry": "https://registry.npmjs.org" | ||
} | ||
} |
@@ -85,3 +85,3 @@ # Node Stream Buffers `v0.2.5` | ||
myReadableStreamBuffer.put("A String", "utf8"); | ||
Chunks are pumped out via standard readable stream spec: | ||
@@ -94,2 +94,4 @@ | ||
Chunks are pumped out by the interval that you specified in frequency. Setting the frequency to 0 will immediately stream the data (also in chunks). This is useful for unit testing. | ||
setEncoding() for streams is respected too: | ||
@@ -96,0 +98,0 @@ |
Sorry, the diff of this file is not supported yet
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
12956
9
176
116