1. is-stream
Check if something is a Node.js stream
is-stream
Package: is-stream
Created by: sindresorhus
Last modified: Mon, 19 Feb 2024 19:14:12 GMT
Version: 4.0.1
License: MIT
Downloads: 297,012,153
Repository: https://github.com/sindresorhus/is-stream

Install

npm install is-stream
yarn add is-stream

is-stream

Check if something is a Node.js stream

Install

 npm install is-stream

Usage

 import fs from 'node:fs';
import {isStream} from 'is-stream';

isStream(fs.createReadStream('unicorn.png'));
//=> true

isStream({});
//=> false

API

isStream(stream, options?)

Returns a boolean for whether it's a Stream.

isWritableStream(stream, options?)

Returns a boolean for whether it's a stream.Writable, an http.OutgoingMessage, an http.ServerResponse or an http.ClientRequest.

isReadableStream(stream, options?)

Returns a boolean for whether it's a stream.Readable or an http.IncomingMessage.

isDuplexStream(stream, options?)

Returns a boolean for whether it's a stream.Duplex.

isTransformStream(stream, options?)

Returns a boolean for whether it's a stream.Transform.

Options

checkOpen

Type: boolean
Default: true

When this option is true, the method returns false if the stream has already been closed.

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin