Stream-like

Test if a value is Node stream-like.

Usage

var isNodeStreamLike = require( '@stdlib/assert/is-node-stream-like' );

isNodeStreamLike( value )

Tests if a value is Node stream-like.

var transformStream = require( '@stdlib/streams/node/transform' );

var bool = isNodeStreamLike( transformStream() );
// returns true

Examples

var stream = require( 'stream' );
var transformStream = require( '@stdlib/streams/node/transform' );
var isNodeStreamLike = require( '@stdlib/assert/is-node-stream-like' );

var bool = isNodeStreamLike( new stream.Stream() );
// returns true

bool = isNodeStreamLike( new stream.Readable() );
// returns true

bool = isNodeStreamLike( new stream.Writable() );
// returns true

bool = isNodeStreamLike( new stream.Duplex() );
// returns true

bool = isNodeStreamLike( new stream.Transform() );
// returns true

bool = isNodeStreamLike( transformStream() );
// returns true

bool = isNodeStreamLike( {} );
// returns false

bool = isNodeStreamLike( [] );
// returns false

bool = isNodeStreamLike( null );
// returns false

function Stream() {
    return this;
}

bool = isNodeStreamLike( Stream );
// returns false

bool = isNodeStreamLike( new Stream() );
// returns false
Did you find this page helpful?