is-stream
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Is-stream is a convenient, lightweight npm package that enables developers to check if a given input is a Node.js stream. It provides a set of functions that return booleans based on whether the provided argument corresponds to a Stream, a Readable stream, a Writable stream, a Duplex stream, or a Transform stream.
To use is-stream, simply install the package via npm with the command npm install is-stream
. Once installed, import it into your file using import {isStream} from 'is-stream';
. You can then use the imported functions to check the type of your streams.
Here's a basic example of how you can use it:
import fs from 'node:fs';
import {isStream} from 'is-stream';
// Create a read stream
const readStream = fs.createReadStream('example.txt');
console.log(isStream(readStream)); // Logs: true
console.log(isStream({})); // Logs: false
This code creates a read stream from a file named 'example.txt' and then uses isStream
to check if it is a stream, which returns true. It also uses isStream
to check if an empty object is a stream, which returns false because the object is not a stream.
Documentation for the is-stream package can be found primarily in the README file within the is-stream repository on GitHub. This file provides an overview of the package, including its installation, usage, and API functionality.