# stdin-discarder

> Discard stdin input except for Ctrl+C

Latest version **0.3.2** (published 2026-04-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install stdin-discarder
pnpm add stdin-discarder
yarn add stdin-discarder
bun add stdin-discarder
```

## Health

**Score 65/100 (B)** — status: active.

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

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.3.2 |
| Published | 2026-04-14 |
| First published | 2022-07-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 4.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 25 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | stdin, process, standard, discard, ignore, input |

## Links

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

## Recent versions

- 0.3.2 (latest) — 2026-04-14
- 0.3.1 — 2026-01-08
- 0.3.0 — 2025-11-04
- 0.2.2 — 2024-01-06
- 0.2.1 — 2023-12-23
- 0.2.0 — 2023-12-15
- 0.1.0 — 2022-07-26

## README

# stdin-discarder

> Discard stdin input except for Ctrl+C

This can be useful to prevent stdin input from interfering with stdout output. For example, you are showing a spinner, and if the user presses a key, it would interfere with the spinner, causing visual glitches. This package prevents such problems.

This has no effect on Windows as there is no good way to implement discarding stdin properly there.

This package is used by [`ora`](https://github.com/sindresorhus/ora) for its [`discardStdin`](https://github.com/sindresorhus/ora#discardstdin) option.

## Install

```sh
npm install stdin-discarder
```

## Usage

```js
import stdinDiscarder from 'stdin-discarder';

stdinDiscarder.start();
```

## API

### stdinDiscarder.start()

Start discarding stdin.

### stdinDiscarder.stop()

Stop discarding stdin.

## Related

- [hook-std](https://github.com/sindresorhus/hook-std) - Hook and modify stdout and stderr

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