time-to-botec/js/node_modules/@stdlib/assert/is-node-duplex-stream-like/README.md
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00

2.3 KiB

Duplex Stream-like

Test if a value is Node duplex stream-like.

Usage

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

isNodeDuplexStreamLike( value )

Tests if a value is Node duplex stream-like.

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

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

Examples

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

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

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

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

bool = isNodeDuplexStreamLike( new stream.Writable() );
// returns false

bool = isNodeDuplexStreamLike( new stream.Readable() );
// returns false

bool = isNodeDuplexStreamLike( new stream.Stream() );
// returns false

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

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

bool = isNodeDuplexStreamLike( null );
// returns false

function Stream() {
    return this;
}

bool = isNodeDuplexStreamLike( Stream );
// returns false

bool = isNodeDuplexStreamLike( new Stream() );
// returns false