# await-repl

> Wrapper for repl faking await functionality

Latest version **1.0.2** (published 2017-01-01) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install await-repl
pnpm add await-repl
yarn add await-repl
bun add await-repl
```

## 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.2 |
| Published | 2017-01-01 |
| First published | 2016-12-31 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Simon Wanner |
| Maintainers | skyrising |
| Keywords | await, repl |

## Links

- npm: https://www.npmjs.com/package/await-repl
- Repository: https://github.com/skyrising/await-repl
- Homepage: https://github.com/skyrising/await-repl#readme
- Issues: https://github.com/skyrising/await-repl/issues
- npm.io page: https://npm.io/package/await-repl

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2017-01-01
- 1.0.1 — 2017-01-01
- 1.0.0 — 2016-12-31

## README

# await-repl
## Wrapper for `repl.start()`

await-repl is a simple wrapper for [repl.start()](https://nodejs.org/api/repl.html#repl_repl_start_options) that handles lines starting with 'await ' differently: instead of outputting the Promise (or value) it only returns when the Promise is resolved or rejected

### Example
```javascript
const awaitRepl = require('await-repl');
awaitRepl({
  rejectionHandler: (err) => 'Promise rejection: ' + err,
  awaitTimeout: 2000
});
```

### Options
await-repl passes options to `repl.start()`

#### Additional options
- __rejectionHandler__  
  function for formatting Promise-rejections  
  it is passed a `callback(err, res)` for returning the formatted error to the repl  
  returning a value is the same as calling `callback(returnValue)`
- __awaitTimeout__  
  number of milliseconds before giving up waiting for Promises to be resolved  
  will act like a Promise-rejection with `new awaitRepl.AwaitTimeout()`

### REPL
```javascript
> await 42
42
> await Promise.resolve(73)
73
> await new Promise((resolve, reject) => setTimeout(() => resolve('foo'), 1000))
/* After 1 second */
'foo'
>
```

#### Previous behavior
```javascript
> 42
42
> Promise.resolve(73)
Promise { 73 }
> new Promise((resolve, reject) => setTimeout(() => resolve('foo'), 1000))
Promise { <pending> }
>
```

### Limitations
Works only for lines __starting__ with 'await ' so things like the following don´t work:
```javascript
> let a = await getSomeValueFromDatabase(...)
```

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