@stdlib/assert-is-node-readable-stream-like
v0.2.2
Published
Test if a value is Node readable stream-like.
Downloads
64
Readme
Readable Stream-like
Test if a value is Node readable stream-like.
Installation
npm install @stdlib/assert-is-node-readable-stream-like
Usage
var isNodeReadableStreamLike = require( '@stdlib/assert-is-node-readable-stream-like' );
isNodeReadableStreamLike( value )
Tests if a value
is Node readable stream-like.
var transformStream = require( '@stdlib/streams-node-transform' );
var bool = isNodeReadableStreamLike( transformStream() );
// returns true
Examples
var stream = require( 'stream' );
var transformStream = require( '@stdlib/streams-node-transform' );
var isNodeReadableStreamLike = require( '@stdlib/assert-is-node-readable-stream-like' );
var bool = isNodeReadableStreamLike( new stream.Readable() );
// returns true
bool = isNodeReadableStreamLike( new stream.Duplex() );
// returns true
bool = isNodeReadableStreamLike( new stream.Transform() );
// returns true
bool = isNodeReadableStreamLike( transformStream() );
// returns true
bool = isNodeReadableStreamLike( new stream.Writable() );
// returns false
bool = isNodeReadableStreamLike( new stream.Stream() );
// returns false
bool = isNodeReadableStreamLike( {} );
// returns false
bool = isNodeReadableStreamLike( [] );
// returns false
bool = isNodeReadableStreamLike( null );
// returns false
function Stream() {
return this;
}
bool = isNodeReadableStreamLike( Stream );
// returns false
bool = isNodeReadableStreamLike( new Stream() );
// returns false
See Also
@stdlib/assert-is-node-stream-like
: test if a value is Node stream-like.
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
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.