.. | ||
index.js | ||
package.json | ||
README.md |
drop-stream
A Duplex stream which discards all chunks passed through.
Usage
Install using:
npm install drop-stream --save
Then pipe through a drop instance:
var DropStream = require('drop-stream'),
PassThrough = require('stream').PassThrough,
opts = {objectMode: true},
pre = new PassThrough(opts),
drop = DropStream.obj(),
post = new PassThrough(opts),
count = 0;
post.on('data', function() {
count++;
});
post.on('finish', function() {
assert.strictEqual(count, 0, count + ' chunks detected'); // won't throw
});
pre.pipe(drop).pipe(post);
pre.write('foo');
pre.write(1);
pre.write({ foobar: 'foobar', answer: 42 });
pre.write('bar');
pre.end();
API
Class: DropStream
Drop streams are Transform streams.
new DropStream([options])
- options
Object
passed through new stream.Transform([options])
Note: The new
operator can be omitted
DropStream#obj([options])
A convenience wrapper for new DropStream({objectMode: true, ...})
.
License
Copyright (c) 2014 Michael Mayer
Licensed under the MIT license.