readme.md (1614B)
1 # is-stream 2 3 > Check if something is a [Node.js stream](https://nodejs.org/api/stream.html) 4 5 ## Install 6 7 ``` 8 $ npm install is-stream 9 ``` 10 11 ## Usage 12 13 ```js 14 import fs from 'node:fs'; 15 import {isStream} from 'is-stream'; 16 17 isStream(fs.createReadStream('unicorn.png')); 18 //=> true 19 20 isStream({}); 21 //=> false 22 ``` 23 24 ## API 25 26 ### isStream(stream) 27 28 Returns a `boolean` for whether it's a [`Stream`](https://nodejs.org/api/stream.html#stream_stream). 29 30 #### isWritableStream(stream) 31 32 Returns a `boolean` for whether it's a [`stream.Writable`](https://nodejs.org/api/stream.html#stream_class_stream_writable). 33 34 #### isReadableStream(stream) 35 36 Returns a `boolean` for whether it's a [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable). 37 38 #### isDuplexStream(stream) 39 40 Returns a `boolean` for whether it's a [`stream.Duplex`](https://nodejs.org/api/stream.html#stream_class_stream_duplex). 41 42 #### isTransformStream(stream) 43 44 Returns a `boolean` for whether it's a [`stream.Transform`](https://nodejs.org/api/stream.html#stream_class_stream_transform). 45 46 ## Related 47 48 - [is-file-stream](https://github.com/jamestalmage/is-file-stream) - Detect if a stream is a file stream 49 50 --- 51 52 <div align="center"> 53 <b> 54 <a href="https://tidelift.com/subscription/pkg/npm-is-stream?utm_source=npm-is-stream&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a> 55 </b> 56 <br> 57 <sub> 58 Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies. 59 </sub> 60 </div>