# on-one

> Subscribe to one or more events and accept the first emitted

Latest version **1.1.3** (published 2026-09-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install on-one
pnpm add on-one
yarn add on-one
bun add on-one
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2026-09-12 |
| First published | 2025-01-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=0.8 |
| Dependencies | 0 |
| Unpacked size | 11.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Kevin Malakoff |
| Maintainers | kmalakoff |
| Keywords | event, emitter, on, trigger, listen, one, once |

## Links

- npm: https://www.npmjs.com/package/on-one
- Repository: https://github.com/kmalakoff/on-one
- Issues: https://github.com/kmalakoff/on-one/issues
- npm.io page: https://npm.io/package/on-one

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.3 (latest) — 2026-09-12
- 1.1.2 — 2026-08-24
- 1.1.1 — 2025-12-17
- 1.1.0 — 2025-12-17
- 1.0.10 — 2025-12-12
- 1.0.9 — 2025-12-12
- 1.0.8 — 2025-12-04
- 1.0.7 — 2025-12-04
- 1.0.6 — 2025-12-03
- 1.0.5 — 2025-11-06
- 1.0.4 — 2025-10-21
- 1.0.3 — 2025-10-21
- 1.0.1 — 2025-06-29
- 0.1.9 — 2025-06-20
- 0.1.8 — 2025-06-18
- … 8 more at https://npm.io/package/on-one/versions

## README

# on-one

Subscribe to one or more events and accept the first emitted.

```bash
npm install on-one
```

```js
var EventEmitter = require('events').EventEmitter;
var onOne = require('on-one');
var emitter = new EventEmitter();

onOne(emitter, ['error', 'finish'], function (err, eventName) {
  if (eventName === 'error') {
    console.error('Stream failed:', err);
  } else {
    console.log('Stream finished successfully');
  }
});

emitter.emit('finish'); // logs the success message
```

The callback receives the error event's error as its first argument. Other
events pass `null`, followed by their event arguments and the event name. After
the first event, all listeners installed by `onOne` are removed.

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