# syncprompt

> A synchronous prompt for node.js

Latest version **2.0.0** (published 2017-07-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install syncprompt
pnpm add syncprompt
yarn add syncprompt
bun add syncprompt
```

## 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 | 2.0.0 |
| Published | 2017-07-23 |
| First published | 2016-12-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 25 |
| Author | Vihan B |
| Maintainers | vihanb |
| Keywords | synchronous, sync, prompt, cli, stdin, readline, read, get, input, io, line |

## Links

- npm: https://www.npmjs.com/package/syncprompt
- Repository: https://github.com/cheddar-lang/syncprompt
- Homepage: https://github.com/cheddar-lang/syncprompt#readme
- Issues: https://github.com/cheddar-lang/syncprompt/issues
- npm.io page: https://npm.io/package/syncprompt

## Dependencies (2)

- [nan](https://npm.io/package/nan.md) ^2.4.0
- [bindings](https://npm.io/package/bindings.md) ^1.2.1

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2017-07-23
- 1.0.3 — 2017-03-21
- 1.0.2 — 2017-03-19
- 1.0.1 — 2016-12-09
- 1.0.0 — 2016-12-09
- 0.0.1 — 2016-12-09

## README

# syncprompt
A _real_ sync-prompt solution for node.

## What is this?
Python users have always add a simple easy way to grab user-input:
```pythono
foo = input()
```

while us JavaScript users are stuck with:
```js
process.stdin.resume()
process.stdin.on('data', function(foo) {
    // ... code
});
```

but those days are long over! This brings an elegant prompt function to node.

---

Well they are other sync-prompt libraries? Hardly, here are the two:

 - [sync-prompt](https://github.com/shovon/sync-prompt), not maintained, doesn't even work on most versions of node anymore
 - [prompt-sync](https://github.com/0x00A/prompt-sync), very flimsy, doesn't properly handle mixed stdin modes, and lacks proper support for more complex stdin reading. Attempts to mimick terminal inputs with raw-mode but breaks easily

So here's a _real_ solution, one that _actually_ mimicks a `getline` or `input` function (uses `getline()` internally).

## Installation
This is easy. Install using:

```shell
$ npm install --save syncprompt
```

Now, in your project, just do:

```js
var prompt = require('syncprompt');
```

or, if you're using the fancy new `import` syntax:

```js
import prompt from 'syncprompt';
```

## Usage
Usage couldn't be more simple. Simple do:

```js
var name = prompt("What's your name? ");
```

Passwords? simply add `secure: true` and you'll get a _real_ hidden password prompt:

```js
var passwords = prompt("Password? ", { secure: true });
```

## Examples
A full example is the following:

```js
var prompt = require('syncprompt');

var username = prompt("Username: ");
var password = prompt("Password: ", { secure: true });

console.log( "Username: %s\nPassword: %s", username, password );
```

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