@stdlib/assert-is-node-duplex-stream-like

Test if a value is Node duplex stream-like.

Usage no npm install needed!

<script type="module">
  import stdlibAssertIsNodeDuplexStreamLike from 'https://cdn.skypack.dev/@stdlib/assert-is-node-duplex-stream-like';
</script>

README

Duplex Stream-like

NPM version Build Status Coverage Status dependencies

Test if a value is Node duplex stream-like.

Installation

npm install @stdlib/assert-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

Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2021. The Stdlib Authors.