githubEdit

isStream

Build Statusarrow-up-right

Test if an object is a Stream

NPMarrow-up-right

The missing Stream.isStream(obj): determine if an object is standard Node.js Stream. Works for Node-core Stream objects (for 0.8, 0.10, 0.11, and in theory, older and newer versions) and all versions of readable-streamarrow-up-right.

Usage:

var isStream = require('isstream')
var Stream = require('stream')

isStream(new Stream()) // true

isStream({}) // false

isStream(new Stream.Readable())    // true
isStream(new Stream.Writable())    // true
isStream(new Stream.Duplex())      // true
isStream(new Stream.Transform())   // true
isStream(new Stream.PassThrough()) // true

But wait! There's more!

You can also test for isReadable(obj), isWritable(obj) and isDuplex(obj) to test for implementations of Streams2 (and Streams3) base classes.

Reminder: when implementing your own streams, please use readable-stream rather than core streamsarrow-up-right.

License

isStream is Copyright (c) 2015 Rod Vagg @rvaggarrow-up-right and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.

Last updated