Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prompts

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prompts - npm Package Compare versions

Comparing version 0.1.0-1 to 0.1.0

4

lib/elements/text.js

@@ -7,7 +7,7 @@ const color = require('clorox');

class TextPrompt extends Prompt {
constructor({ message, cursor, initial = '', style = 'default' }) {
constructor({ message, cursor, initial, style = 'default' }) {
super();
this.msg = message;
this.value = initial;
this.value = initial || '';

@@ -14,0 +14,0 @@ this.initialValue = this.value;

@@ -22,3 +22,3 @@ 'use strict';

let value = prompt[key];
prompt[key] = typeof value === 'function' ? await value(answer, { ...answers }) : value;
prompt[key] = typeof value === 'function' ? await value(answer, { ...answers }, prompt) : value;
}

@@ -25,0 +25,0 @@

'use strict';
const el = require('./elements');
const s = module.exports;

@@ -84,3 +83,3 @@ /**

p.on('submit', str => resolve(str.split(separator).map(s => s.trim())));
p.on('abort', str => reject(str.split(separator).map(s => trim.trim())));
p.on('abort', reject);
});

@@ -154,3 +153,2 @@ }

if (!Array.isArray(choices)) throw new Error('choices array is required');
const suggestByTitle = (input, choices) =>

@@ -157,0 +155,0 @@ Promise.resolve(

{
"name": "prompts",
"version": "0.1.0-1",
"version": "0.1.0",
"description": "Lightweight, beautiful and user-friendly prompts",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/terkelg/prompts",

@@ -5,3 +5,3 @@ <div align="center">

<h1 align="center">Prompts</h1>
<h1 align="center">❯ Prompts</h1>

@@ -22,3 +22,3 @@ <div align="center">

<b>Lightweight, beautiful and user-friendly interactive prompts</b></br>
<sub>>_ Easy to use CLI prompts to inquire users for information ▌<sub>
<sub>>_ Easy to use CLI prompts to enquire users for information▌<sub>
</div>

@@ -30,6 +30,9 @@

* **User friendly**: prompt uses layout and colors to create beautiful cli interfaces.
* **Promised**: Uses promises and `async`/`await`. No callback hell.
* **Flexible**: All prompts are independet and can be used on their own.
* **Promised**: uses promises and `async`/`await`. No callback hell.
* **Flexible**: all prompts are independent and can be used on their own.
![split](https://github.com/terkelg/prompts/raw/master/media/split.png)
## ❯ Install

@@ -41,3 +44,6 @@

> This package uses async/await and requires Node.js 7.6
![split](https://github.com/terkelg/prompts/raw/master/media/split.png)
## ❯ Usage

@@ -60,2 +66,5 @@

![split](https://github.com/terkelg/prompts/raw/master/media/split.png)
## ❯ Examples

@@ -76,3 +85,3 @@

// response => { name }
console.log(response.meaning);
```

@@ -127,3 +136,3 @@

{
type: prev => prev.type == 'pizza' ? 'text' : null,
type: prev => prev == 'pizza' ? 'text' : null,
name: 'topping',

@@ -138,2 +147,5 @@ message: 'Name a topping'

![split](https://github.com/terkelg/prompts/raw/master/media/split.png)
## ❯ API

@@ -146,3 +158,3 @@

Prompter function which takes your [prompt objects](#-prompt-objects) and returns an object with answers
Prompter function which takes your [prompt objects](#-prompt-objects) and returns an object with responses.

@@ -164,10 +176,10 @@

Callback that's invoked after each prompt submission.
Its signature is `(prompt, answer)` where `prompt` is the current prompt object.
Its signature is `(prompt, response)` where `prompt` is the current prompt object.
Return `true` to quit the prompt loop and return all collected answers so far, otherwise continue to iterate prompt objects.
Return `true` to quit the prompt chain and return all collected responses so far, otherwise continue to iterate prompt objects.
**Example:**
```
```js
let questions = [{ ... }];
let onSubmit = (prompt, answer) => console.log(`Thanks I got ${answer} from ${prompt.name}`);
let onSubmit = (prompt, response) => console.log(`Thanks I got ${response} from ${prompt.name}`);
let response = await prompts(questions, { onSubmit });

@@ -181,9 +193,9 @@ ```

Callback that's invoked after when the user cancel/exit the prompt.
Callback that's invoked when the user cancel/exit the prompt.
Its signature is `(prompt)` where `prompt` is the current prompt object.
Return `true` to quit the prompt loop and return all collected answers so far, otherwise continue to iterate prompt objects.
Return `true` to quit the prompt loop and return all collected responses so far, otherwise continue to iterate prompt objects.
**Example:**
```
```js
let questions = [{ ... }];

@@ -198,2 +210,5 @@ let onCancel = prompt => {

![split](https://github.com/terkelg/prompts/raw/master/media/split.png)
## ❯ Prompt Objects

@@ -232,3 +247,9 @@

Its signature is `(prev, values, prompt)`, where `prev` is the value from the previous prompt,
`values` is all values collected so far and `prompt` is the provious prompt object.
![split](https://github.com/terkelg/prompts/raw/master/media/split.png)
## ❯ Types

@@ -287,4 +308,4 @@

This prompt is similar to what you know from `sudo`.
This prompt is a simular to a prompt of type `'text'` with style set to `'invisible'`.
This prompt is working like `sudo` where the input is invisible.
This prompt is a similar to a prompt of type `'text'` with style set to `'invisible'`.

@@ -378,3 +399,3 @@ #### Example

initial: '',
separator: ', '
separator: ','
}

@@ -390,3 +411,3 @@ ```

| initial | <code>boolean</code> | <code>false</code> | Default value |
| seperator | <code>string</code> | <code>", "</code> | String seperator |
| seperator | <code>string</code> | <code>','</code> | String seperator. Will trim all white-spaces from start and end of string |

@@ -494,4 +515,4 @@

The default suggets/filter function is based on the `title` property.
You can overwrite this by passing your own filter function.
The default suggets function is sorting based on the `title` property of the choices.
You can overwrite how choices are being filtered by passing your own suggest function.

@@ -521,3 +542,3 @@ #### Example

| choices | <code>Array</code> | | Array of auto-complete choices objects `[{ title, value }, ...]` |
| suggest | <code>function</code> | By `title` string | Filter function. Defaults to stort by `title` property |
| suggest | <code>function</code> | By `title` string | Filter function. Defaults to stort by `title` property. Suggest should always return a promise |
| limit | <code>number</code> | <code>10</code> | Max number of results to show |

@@ -534,2 +555,5 @@ | style | <code>string</code> | `'default'` | Render style (`default`, `password`, `invisible`) |

![split](https://github.com/terkelg/prompts/raw/master/media/split.png)
## ❯ Credit

@@ -541,2 +565,2 @@ Many of the prompts are based on the work of [derhuerst](https://github.com/derhuerst).

MIT © [Terkel Gjervig](https://terkel.com)
MIT © [Terkel Gjervig](https://terkel.com)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc