# readline-once

> readline-once =============

Latest version **1.0.1** (published 2016-03-17) · MIT license · 0 weekly downloads

## Install

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

## 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.1 |
| Published | 2016-03-17 |
| First published | 2016-03-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Quentin Engles |
| Maintainers | hollowdoor |
| Keywords | readline, modular |

## Links

- npm: https://www.npmjs.com/package/readline-once
- npm.io page: https://npm.io/package/readline-once

## Dependencies (1)

- [split](https://npm.io/package/split.md) ^1.0.0

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2016-03-17
- 1.0.0 — 2016-03-16

## README

readline-once
=============

Install
-------

`npm install --save readline-once`

Examples
--------

With normal strings.

```javascript
var rlonce = require('readline-once')();

rlonce('first name? ', true).then(function(val){
    console.log('first name = '+val)

    return rlonce('last name? ').then(function(val){
        console.log('last name = '+val)
    });

}).catch(function(e){
    console.log('error! ', e);
});
```

With an array.

```javascript
var rlonce = require('readline-once')();

rlonce(['first name? ', 'last name? ']).then(function(fullname){
    console.log('full name = '+fullname.join(' '));
}).catch(function(e){
    console.log(e);
});
```

API
---

### factory(undefined|readline)

Get the factory by importing the module.

```javascript
var factory = require('readline-once'),
    rlonce = factory();
```

Or use you're own instance of `readline`.

```javascript
var factory = require('readline-once'),
    rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    }),
    rlonce = factory(rl);
```

Or call it all at once.

```javascript
var rlonce = require('readline-once')();
```

With readline passed to the factory.

```javascript
var rlonce = require('readline-once')(readline.createInterface({
    input: process.stdin,
    output: process.stdout
}));
```

### rlonce(question|array, require) -> Promise

Ask a **question**, or pass an **array of questions**.

The **require** argument forces the question(s) to be asked again if it's not filled out.

About
-----

Sometimes it's nice to just have a one shot readline call.

This function will also work nicely with coroutines, and async await.

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