Comparing version 0.6.2 to 0.6.3
{ | ||
"name": "through2", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"description": "A tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise", | ||
@@ -23,3 +23,3 @@ "main": "through2.js", | ||
"dependencies": { | ||
"readable-stream": ">=1.0.28 <1.1.0-0", | ||
"readable-stream": ">=1.0.33-1 <1.1.0-0", | ||
"xtend": ">=4.0.0 <4.1.0-0" | ||
@@ -26,0 +26,0 @@ }, |
@@ -31,3 +31,2 @@ # through2 | ||
.pipe(through2(function (chunk, enc, callback) { | ||
for (var i = 0; i < chunk.length; i++) | ||
@@ -40,3 +39,2 @@ if (chunk[i] == 97) | ||
callback() | ||
})) | ||
@@ -54,3 +52,2 @@ .pipe(fs.createWriteStream('out.txt')) | ||
.pipe(through2.obj(function (chunk, enc, callback) { | ||
var data = { | ||
@@ -61,7 +58,5 @@ name : chunk[0] | ||
} | ||
this.push(data) | ||
callback() | ||
})) | ||
@@ -92,8 +87,8 @@ .on('data', function (data) { | ||
fs.createReadStream('/tmp/important.dat') | ||
.pipe(through2({ objectMode: true, allowHalfOpen: false }, function (chunk, enc, cb) { | ||
this.push(new Buffer('wut?')) | ||
cb() | ||
}) | ||
.pipe(through2({ objectMode: true, allowHalfOpen: false }, | ||
function (chunk, enc, cb) { | ||
cb(null, 'wut?') // note we can use the second argument on the callback | ||
// to provide data as an alternative to this.push('wut?') | ||
} | ||
) | ||
.pipe(fs.createWriteStream('/tmp/wut.txt')) | ||
@@ -116,2 +111,14 @@ ``` | ||
```js | ||
fs.createReadStream('/tmp/important.dat') | ||
.pipe(through2( | ||
function (chunk, enc, cb) { cb(null, chunk) }, // transform is a noop | ||
function (cb) { // flush function | ||
this.push('tacking on an extra buffer to the end'); | ||
cb(); | ||
} | ||
)) | ||
.pipe(fs.createWriteStream('/tmp/wut.txt')); | ||
``` | ||
<b><code>through2.ctor([ options, ] transformFunction[, flushFunction ])</code></b> | ||
@@ -118,0 +125,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
10856
150