Awesome
is-node-stream
Strictly and correctly checks if value is a nodejs stream.
Install
npm i is-node-stream --save
Usage
For more use-cases see the tests
var stream = require('stream')
var isNodeStream = require('is-node-stream')
isNodeStream(val) returns true
when
isNodeStream(new stream.Stream())
isNodeStream(new stream.Duplex())
isNodeStream(new stream.Readable())
isNodeStream(new stream.Writable())
isNodeStream(new stream.Transform())
isNodeStream(new stream.PassThrough())
isNodeStream(new net.Socket())
isNodeStream(fs.createReadStream('package.json'))
isNodeStream.readable(val) returns true
when
isNodeStream.readable(process.stdin)
isNodeStream.readable(new stream.Duplex())
isNodeStream.readable(new stream.Readable())
isNodeStream.readable(new stream.Transform())
isNodeStream.readable(new stream.PassThrough())
isNodeStream.readable(fs.createReadStream('package.json'))
isNodeStream.writable(val) returns true
when
isNodeStream.writable(process.stdout)
isNodeStream.writable(new stream.Duplex())
isNodeStream.writable(new stream.Writable())
isNodeStream.writable(new stream.Transform())
isNodeStream.writable(new stream.PassThrough())
isNodeStream.writable(fs.createWriteStream('foobar'))
isNodeStream.duplex(val) returns true
when
isNodeStream.duplex(new stream.Duplex())
isNodeStream.duplex(new stream.Transform())
isNodeStream.duplex(new stream.PassThrough())
Related
- dush: Minimalist 1.5kb event delegation for the browser (IE8+) and nodejs.
- is-emitter: Check that given value is EventEmitter, not so strict as
is-node-emitter
. - is-node-emitter: Strictly checks that given value is nodejs EventEmitter… more
- is-stream: Check if something is a Node.js stream
- to-emitter: Convert any object into an event-emitter, and emits events with the… more
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.