# once-then

> Add onceThen to your emitter to convert an event to a Promise.

Latest version **1.1.0** (published 2017-03-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install once-then
pnpm add once-then
yarn add once-then
bun add once-then
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2017-03-22 |
| First published | 2017-03-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Dieter Luypaert |
| Maintainers | moeriki |
| Keywords | events, promises |

## Links

- npm: https://www.npmjs.com/package/once-then
- Repository: https://github.com/Moeriki/node-once-then
- Homepage: https://github.com/Moeriki/node-once-then#readme
- Issues: https://github.com/Moeriki/node-once-then/issues
- npm.io page: https://npm.io/package/once-then

## Dependencies (1)

- [register-toggle](https://npm.io/package/register-toggle.md) ^2.1.0

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2017-03-22
- 1.0.0 — 2017-03-20

## README

<p align="center">
  <h3 align="center">once-then</h3>
  <p align="center">Add onceThen to your emitter to convert an event to a Promise.<p>
  <p align="center">
    <a href="https://www.npmjs.com/package/once-then">
      <img src="https://img.shields.io/npm/v/once-then.svg" alt="npm version">
    </a>
    <a href="https://travis-ci.org/Moeriki/node-once-then">
      <img src="https://travis-ci.org/Moeriki/node-once-then.svg?branch=master" alt="Build Status"></img>
    </a>
    <a href="https://coveralls.io/github/Moeriki/node-once-then?branch=master">
      <img src="https://coveralls.io/repos/github/Moeriki/node-once-then/badge.svg?branch=master" alt="Coverage Status"></img>
    </a>
    <a href="https://david-dm.org/moeriki/node-mappr">
      <img src="https://david-dm.org/moeriki/node-once-then/status.svg" alt="dependencies Status"></img>
    </a>
  </p>
</p>

## Installation

```
npm install --save once-then
```

## Usage

```js
const EventEmitter = require('events').EventEmitter;
const onceThen = require('once-then');
```

`onceThen` works with the NodeJS event emitter or any events implementation that has its `once` method backwards compatible with NodeJS events.

```js
const emitter = new EventEmitter();

onceThen(emitter, 'myEventName').then(() => {
  //
});

emitter.emit('myEventName');
```

### Register

Register `onceThen` on an object.

```js
onceThen.register(EventEmitter.prototype);

const emitter = new EventEmitter();

emitter.onceThen('myEventName').then(() => {
  //
});

emitter.emit('myEventName');
```

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