Socket
Socket
Sign inDemoInstall

prompt-promise

Package Overview
Dependencies
3
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    prompt-promise

Sane CLI user-input (command prompt, confirm, multiline, password) as promises, it can be used with co@4


Version published
Weekly downloads
2.9K
decreased by-16.44%
Maintainers
1
Install size
52.3 kB
Created
Weekly downloads
 

Readme

Source

npm mit license build status coverage status deps status

Sane CLI user-input (command prompt, confirm, multiline, password) as promises, it can be used with co@4

Install

npm i --save prompt-promise

Run examples

npm run with-co
npm run without-co

Usage

For more use-cases see examples

var co = require('co');
var prompt = require('prompt-promise');
var res = [];

prompt('username: ')
.then(function username(val) {
  res.push(val);
  return prompt.password('password: ');
})
.then(function pasword(val) {
  res.push(val);
  console.log(res);
  prompt.done();
})
.catch(function rejected(err) {
  console.log('error:', err.stack);
  prompt.finish();
});

// or with `co@4`
co(function * genPrompt() {
  var username = yield prompt('username: ');
  var password = yield prompt.password('password: ');

  return yield [username, password];
})
.then(function fulfilled(array) {
  console.log('response:', array);
  prompt.end();
})
.catch(function rejected(err) {
  console.log('error:', err.stack);
  process.stdin.pause();
});

.end(), .done(), .finish() are just aliases for process.stdin.pause(); its required, nah..

Author

Charlike Mike Reagent

License MIT license

Copyright (c) 2014-2015 Charlike Mike Reagent, contributors.
Copyright (c) 2014 TJ Holowaychuk, contributors.
Released under the MIT license.


Powered and automated by kdf, January 31, 2015

Keywords

FAQs

Last updated on 31 Jan 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc