Skip to content

mongodb-js/askpassword

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

askpassword

A password prompt that does not print data to the TTY.

import askpassword from 'askpassword';

console.log('Please enter a password:');
const password = await askpassword(process.stdin);
console.log('You entered the following password:', password.toString());

The stream passed to askpassword can be any kind of Readable stream. If it is a TTY, askpassword will temporarily remove all other 'data' and 'readable' listeners from it, and set the TTY into raw mode if it has not been in raw mode to begin with.

Why not use read instead?

Because read does not work inside a Node.js REPL.

LICENSE

Apache-2.0

About

A password prompt that does print data to the TTY

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •