📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP

isstream

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isstream

Determine if an object is a Stream

0.1.2
latest
Version published
Weekly downloads
19M
42.35%
Maintainers
1
Weekly downloads
 
Created

What is isstream?

The isstream npm package is a simple utility to check if an object is a stream. It provides functions to determine if an object is a readable, writable, or duplex stream.

What are isstream's main functionalities?

Check if an object is a stream

This feature allows you to check if a given object is a stream. In this example, we use the fs module to create a readable stream and then check if it is a stream using isStream.

const isStream = require('isstream');
const fs = require('fs');

const readableStream = fs.createReadStream('example.txt');
console.log(isStream(readableStream)); // true

Check if an object is a readable stream

This feature allows you to check if a given object is a readable stream. In this example, we use the fs module to create a readable stream and then check if it is a readable stream using isStream.isReadable.

const isStream = require('isstream');
const fs = require('fs');

const readableStream = fs.createReadStream('example.txt');
console.log(isStream.isReadable(readableStream)); // true

Check if an object is a writable stream

This feature allows you to check if a given object is a writable stream. In this example, we use the fs module to create a writable stream and then check if it is a writable stream using isStream.isWritable.

const isStream = require('isstream');
const fs = require('fs');

const writableStream = fs.createWriteStream('example.txt');
console.log(isStream.isWritable(writableStream)); // true

Check if an object is a duplex stream

This feature allows you to check if a given object is a duplex stream. In this example, we create a duplex stream using the stream module and then check if it is a duplex stream using isStream.isDuplex.

const isStream = require('isstream');
const { Duplex } = require('stream');

const duplexStream = new Duplex();
console.log(isStream.isDuplex(duplexStream)); // true

Other packages similar to isstream

FAQs

Package last updated on 07 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts