# is-stream

> Check if something is a Node.js stream

Latest version **4.0.1** (published 2024-02-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install is-stream
pnpm add is-stream
yarn add is-stream
bun add is-stream
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2024-02-19 |
| First published | 2015-01-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 115 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | stream, type, streams, writable, readable, duplex, transform, check, detect, is |

## Links

- npm: https://www.npmjs.com/package/is-stream
- Repository: https://github.com/sindresorhus/is-stream
- Homepage: https://github.com/sindresorhus/is-stream#readme
- Issues: https://github.com/sindresorhus/is-stream/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/is-stream

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 4.0.1 (latest) — 2024-02-19
- 4.0.0 — 2024-02-19
- 3.0.0 — 2021-08-10
- 2.0.1 — 2021-07-26
- 2.0.0 — 2019-04-20
- 1.1.0 — 2016-04-12
- 1.0.1 — 2015-01-19
- 1.0.0 — 2015-01-18

## README

# is-stream

> Check if something is a [Node.js stream](https://nodejs.org/api/stream.html)

## Install

```sh
npm install is-stream
```

## Usage

```js
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`](https://nodejs.org/api/stream.html#stream_stream).

### isWritableStream(stream, options?)

Returns a `boolean` for whether it's a [`stream.Writable`](https://nodejs.org/api/stream.html#stream_class_stream_writable), an [`http.OutgoingMessage`](https://nodejs.org/api/http.html#class-httpoutgoingmessage), an [`http.ServerResponse`](https://nodejs.org/api/http.html#class-httpserverresponse) or an [`http.ClientRequest`](https://nodejs.org/api/http.html#class-httpserverresponse).

### isReadableStream(stream, options?)

Returns a `boolean` for whether it's a [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable) or an [`http.IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage).

### isDuplexStream(stream, options?)

Returns a `boolean` for whether it's a [`stream.Duplex`](https://nodejs.org/api/stream.html#stream_class_stream_duplex).

### isTransformStream(stream, options?)

Returns a `boolean` for whether it's a [`stream.Transform`](https://nodejs.org/api/stream.html#stream_class_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

- [is-file-stream](https://github.com/jamestalmage/is-file-stream) - Detect if a stream is a file stream

---
_Source: https://npm.io/package/is-stream · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
