-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
filter-validate-progress.js
40 lines (37 loc) · 1001 Bytes
/
filter-validate-progress.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* Filter and validate progress example
*/
import inquirer from '../lib/inquirer.js';
const questions = [
{
type: 'input',
name: 'first_question',
message: 'Question with filtering and validating text',
async validate() {
await new Promise((r) => setTimeout(r, 3000));
return true;
},
async filter(answer) {
await new Promise((r) => setTimeout(r, 3000));
return `filtered${answer}`;
},
filteringText: 'Filtering your answer...',
validatingText: 'Validating what you wrote...',
},
{
type: 'input',
name: 'second_question',
message: 'Question without filtering and validating text',
async validate() {
await new Promise((r) => setTimeout(r, 3000));
return true;
},
async filter(answer) {
await new Promise((r) => setTimeout(r, 3000));
return `filtered${answer}`;
},
},
];
inquirer.prompt(questions).then((answers) => {
console.log(JSON.stringify(answers, null, ' '));
});