is-stream

  • Version 3.0.0
  • Published
  • 6.23 kB
  • No dependencies
  • MIT license

Install

npm i is-stream
yarn add is-stream
pnpm add is-stream

Overview

Check if something is a Node.js stream

Index

Functions

function isDuplexStream

isDuplexStream: (stream: unknown) => stream is any;
  • Returns

    Whether stream is a [stream.Duplex](https://nodejs.org/api/stream.html#stream_class_stream_duplex).

    Example 1

    import {Duplex as DuplexStream} from 'node:stream';
    import {isDuplexStream} from 'is-stream';
    isDuplexStream(new DuplexStream());
    //=> true

function isReadableStream

isReadableStream: (stream: unknown) => stream is any;
  • Returns

    Whether stream is a [stream.Readable](https://nodejs.org/api/stream.html#stream_class_stream_readable).

    Example 1

    import fs from 'node:fs';
    import {isReadableStream} from 'is-stream';
    isReadableStream(fs.createReadStream('unicorn.png'));
    //=> true

function isStream

isStream: (stream: unknown) => stream is any;
  • Returns

    Whether stream is a [Stream](https://nodejs.org/api/stream.html#stream_stream).

    Example 1

    import fs from 'node:fs';
    import {isStream} from 'is-stream';
    isStream(fs.createReadStream('unicorn.png'));
    //=> true
    isStream({});
    //=> false

function isTransformStream

isTransformStream: (stream: unknown) => stream is any;
  • Returns

    Whether stream is a [stream.Transform](https://nodejs.org/api/stream.html#stream_class_stream_transform).

    Example 1

    import fs from 'node:fs';
    import StringifyStream from 'streaming-json-stringify';
    import {isTransformStream} from 'is-stream';
    isTransformStream(StringifyStream());
    //=> true

function isWritableStream

isWritableStream: (stream: unknown) => stream is any;
  • Returns

    Whether stream is a [stream.Writable](https://nodejs.org/api/stream.html#stream_class_stream_writable).

    Example 1

    import fs from 'node:fs';
    import {isWritableStream} from 'is-stream';
    isWritableStream(fs.createWriteStrem('unicorn.txt'));
    //=> true

Package Files (1)

Dependencies (0)

No dependencies.

Dev Dependencies (5)

Peer Dependencies (0)

No peer dependencies.

Badge

To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/is-stream.

  • Markdown
    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/is-stream)
  • HTML
    <a href="https://www.jsdocs.io/package/is-stream"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>