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

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code