Skip to content

Commit

Permalink
add: list/option-no-empty-string.js
Browse files Browse the repository at this point in the history
Add a list prompt example that filters out
all the empty strings in the resulting array.
Closes #174
  • Loading branch information
rajat-sr committed Jul 2, 2019
1 parent 55923c2 commit 811a078
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions examples/list/option-no-empty-string.js
@@ -0,0 +1,14 @@
'use strict';
/* This example filters out all the empty string added in the result */
const { List } = require('enquirer');
const prompt = new List({
name: 'keywords',
message: 'Type comma-separated keywords',
result(answers) {
return answers.filter(Boolean);
}
});

prompt.run()
.then(answer => console.log('Answer:', answer))
.catch(console.error);

0 comments on commit 811a078

Please sign in to comment.