concat-stream
Advanced tools
Comparing version 0.1.1 to 1.0.0
@@ -10,3 +10,3 @@ var stream = require('stream') | ||
this.on('error', function(err) { | ||
if (this.cb) this.cb(err) | ||
// no-op | ||
}) | ||
@@ -44,3 +44,3 @@ } | ||
ConcatStream.prototype.end = function() { | ||
if (this.cb) this.cb(false, this.getBody()) | ||
if (this.cb) this.cb(this.getBody()) | ||
} | ||
@@ -47,0 +47,0 @@ |
{ "name" : "concat-stream" | ||
, "description" : "writable stream that concatenates strings or data and calls a callback with the result" | ||
, "tags" : ["stream", "simple", "util", "utility"] | ||
, "version" : "0.1.1" | ||
, "version" : "1.0.0" | ||
, "author" : "Max Ogden <max@maxogden.com>" | ||
@@ -6,0 +6,0 @@ , "repository" : |
# concat-stream | ||
npm install concat-stream | ||
```sh | ||
$ npm install concat-stream | ||
``` | ||
then | ||
var concat = require('concat-stream') | ||
var fs = require('fs') | ||
```js | ||
var concat = require('concat-stream') | ||
var fs = require('fs') | ||
var read = fs.createReadStream('readme.md') | ||
var write = concat(function(err, data) {}) | ||
var read = fs.createReadStream('readme.md') | ||
var write = concat(function(data) {}) | ||
read.pipe(write) | ||
read.pipe(write) | ||
``` | ||
works with arrays too! | ||
var write = concat(function(err, data) {}) | ||
write.write([1,2,3]) | ||
write.write([4,5,6]) | ||
write.end() | ||
// data will be [1,2,3,4,5,6] in the above callback | ||
```js | ||
var write = concat(function(data) {}) | ||
write.write([1,2,3]) | ||
write.write([4,5,6]) | ||
write.end() | ||
// data will be [1,2,3,4,5,6] in the above callback | ||
``` | ||
works with buffers too! can't believe the deals! | ||
var write = concat(function(err, data) {}) | ||
write.write(new Buffer('hello ')) | ||
write.write(new Buffer('world')) | ||
write.end() | ||
// data will be a buffer that toString()s to 'hello world' in the above callback | ||
MIT LICENSE | ||
```js | ||
var write = concat(function(data) {}) | ||
write.write(new Buffer('hello ')) | ||
write.write(new Buffer('world')) | ||
write.end() | ||
// data will be a buffer that toString()s to 'hello world' in the above callback | ||
``` | ||
MIT LICENSE |
16
test.js
@@ -7,4 +7,4 @@ var spawn = require('child_process').spawn | ||
cmd.stdout.pipe( | ||
concat(function(err, out) { | ||
console.log('`ls`', err, out.toString()) | ||
concat(function(out) { | ||
console.log('`ls`', out.toString()) | ||
}) | ||
@@ -14,4 +14,4 @@ ) | ||
// array stream | ||
var arrays = concat(function(err, out) { | ||
console.log('arrays', err, out) | ||
var arrays = concat(function(out) { | ||
console.log('arrays', out) | ||
}) | ||
@@ -23,4 +23,4 @@ arrays.write([1,2,3]) | ||
// buffer stream | ||
var buffers = concat(function(err, out) { | ||
console.log('buffers', err, out.toString()) | ||
var buffers = concat(function(out) { | ||
console.log('buffers', out.toString()) | ||
}) | ||
@@ -32,4 +32,4 @@ buffers.write(new Buffer('pizza Array is not a ', 'utf8')) | ||
// string stream | ||
var strings = concat(function(err, out) { | ||
console.log('strings', err, out) | ||
var strings = concat(function(out) { | ||
console.log('strings', out) | ||
}) | ||
@@ -36,0 +36,0 @@ strings.write("nacho ") |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
39
3093