time-to-botec/squiggle/node_modules/@stdlib/assert/is-node-writable-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

Writable Stream-like

Test if a value is Node writable stream-like.

Usage

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

isNodeWritableStreamLike( value )

Tests if a value is Node writable stream-like.

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

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

Examples

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

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

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

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

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

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

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

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

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

bool = isNodeWritableStreamLike( null );
// returns false

function Stream() {
    return this;
}

bool = isNodeWritableStreamLike( Stream );
// returns false

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