README.md (2397B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # Readable Stream-like 22 23 > Test if a value is Node [readable stream][nodejs-stream]-like. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var isNodeReadableStreamLike = require( '@stdlib/assert/is-node-readable-stream-like' ); 31 ``` 32 33 #### isNodeReadableStreamLike( value ) 34 35 Tests if a `value` is Node [readable stream][nodejs-stream]-like. 36 37 ```javascript 38 var transformStream = require( '@stdlib/streams/node/transform' ); 39 40 var bool = isNodeReadableStreamLike( transformStream() ); 41 // returns true 42 ``` 43 44 </section> 45 46 <!-- /.usage --> 47 48 <section class="notes"> 49 50 </section> 51 52 <!-- /.notes --> 53 54 <section class="examples"> 55 56 ## Examples 57 58 <!-- eslint no-undef: "error" --> 59 60 ```javascript 61 var stream = require( 'stream' ); 62 var transformStream = require( '@stdlib/streams/node/transform' ); 63 var isNodeReadableStreamLike = require( '@stdlib/assert/is-node-readable-stream-like' ); 64 65 var bool = isNodeReadableStreamLike( new stream.Readable() ); 66 // returns true 67 68 bool = isNodeReadableStreamLike( new stream.Duplex() ); 69 // returns true 70 71 bool = isNodeReadableStreamLike( new stream.Transform() ); 72 // returns true 73 74 bool = isNodeReadableStreamLike( transformStream() ); 75 // returns true 76 77 bool = isNodeReadableStreamLike( new stream.Writable() ); 78 // returns false 79 80 bool = isNodeReadableStreamLike( new stream.Stream() ); 81 // returns false 82 83 bool = isNodeReadableStreamLike( {} ); 84 // returns false 85 86 bool = isNodeReadableStreamLike( [] ); 87 // returns false 88 89 bool = isNodeReadableStreamLike( null ); 90 // returns false 91 92 function Stream() { 93 return this; 94 } 95 96 bool = isNodeReadableStreamLike( Stream ); 97 // returns false 98 99 bool = isNodeReadableStreamLike( new Stream() ); 100 // returns false 101 ``` 102 103 </section> 104 105 <!-- /.examples --> 106 107 <section class="links"> 108 109 [nodejs-stream]: https://nodejs.org/api/stream.html 110 111 </section> 112 113 <!-- /.links -->