# signal-promise

> Simple wait/notify promise with optional max wait time

Latest version **1.0.3** (published 2020-03-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install signal-promise
pnpm add signal-promise
yarn add signal-promise
bun add signal-promise
```

## 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.0.3 |
| Published | 2020-03-03 |
| First published | 2020-03-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 45 |
| Author | Mathias Buus |
| Maintainers | mafintosh |

## Links

- npm: https://www.npmjs.com/package/signal-promise
- Repository: https://github.com/mafintosh/signal-promise
- Issues: https://github.com/mafintosh/signal-promise/issues
- npm.io page: https://npm.io/package/signal-promise

## Recent versions

- 1.0.3 (latest) — 2020-03-03
- 1.0.2 — 2020-03-03
- 1.0.1 — 2020-03-03
- 1.0.0 — 2020-03-03
- 0.0.0 — 2020-03-03

## README

# signal-promise

Simple wait/notify promise with optional max wait time

```
npm install signal-promise
```

## Usage

``` js
const Signal = require('signal-promise')

const input = new Signal()

while (await input.wait()) {
  console.log('someone typed!')
}

process.stdin.on('stdin', function () {
  input.notify()
})
```

## API

#### `s = new Signal()`

Make a new signal

#### `await s.wait([maxWaitTime])`

Wait for someone to call notify. If you specify `maxWaitTime`
the promise will resolve after `maxWaitTime` ms if no notify call has happened.

As a convenience the promise resolves to `true` so it's easy to use it as a condition.

#### `s.notify([error])`

Notify everyone waiting. If you pass an error the wait promise
will reject with that error.

## License

MIT

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