Comparing version 1.0.1 to 1.1.0
@@ -10,2 +10,3 @@ var stream = require('stream'); | ||
this.buffer = []; | ||
this.length = 0; | ||
} | ||
@@ -15,2 +16,3 @@ | ||
this.buffer.push(chunk); | ||
this.length += chunk.length; | ||
callback(); | ||
@@ -34,1 +36,5 @@ }; | ||
}; | ||
StreamSink.prototype.toBuffer = function() { | ||
return Buffer.concat(this.buffer, this.length); | ||
}; |
{ | ||
"name": "streamsink", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "pipe to a buffer, then create readable streams from it", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -0,1 +1,5 @@ | ||
# node-streamsink | ||
See also [bl](https://github.com/rvagg/bl). | ||
## Usage | ||
@@ -12,3 +16,9 @@ | ||
sink.createReadStream().pipe(someDestination); | ||
// or use toString([encoding]) | ||
console.log(sink.toString('utf8')); | ||
// or use toBuffer() | ||
sink.toBuffer(); | ||
}); | ||
``` |
@@ -10,2 +10,6 @@ var StreamSink = require('./'); | ||
assert.strictEqual(newSink.toString(), "hi"); | ||
var buf = sink.toBuffer(); | ||
assert.strictEqual(buf.length, 2); | ||
assert.strictEqual(buf[0], 104); | ||
assert.strictEqual(buf[1], 105); | ||
console.log("OK"); | ||
@@ -12,0 +16,0 @@ }); |
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
3449
5
49
24