# just-promise-once

> Use once listener as a promise

Latest version **0.1.1** (published 2020-09-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install just-promise-once
pnpm add just-promise-once
yarn add just-promise-once
bun add just-promise-once
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2020-09-25 |
| First published | 2020-08-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Michael Szmadzinski |
| Maintainers | smujmaiku |

## Links

- npm: https://www.npmjs.com/package/just-promise-once
- Repository: https://github.com/smujmaiku/just-promise-once
- Homepage: https://github.com/smujmaiku/just-promise-once#readme
- Issues: https://github.com/smujmaiku/just-promise-once/issues
- npm.io page: https://npm.io/package/just-promise-once

## Dependencies (1)

- [just-defer](https://npm.io/package/just-defer.md) ^0.1.2

## Recent versions

- 0.1.1 (latest) — 2020-09-25
- 0.1.0 — 2020-08-26

## README

# Just Promise Once

Do you need to await on a `once` event?
Would you like to avoid callbacks in callbacks with your eventlisteners?
Has your socket.io authentication logic gotten out of hand?

Just Promise Once!

## Installation

`npm i just-promise-once`

## Usage

Socket.io authorization

```js
async function socketConnection(socket) {
	// Handle authorization first
	const [authorization] = await justPromiseOnce(socket, 'authorization', AUTH_TIMEOUT);
	await handleAuthorization(authorization);

	// Secure protected methods
	socket.on('protectedMethod', handleProtectedMethods);
}
```

## License

Copyright (c) 2020, Michael Szmadzinski. (MIT License)

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