Gathering detailed insights and metrics for @kant2002/prompt-sync
Gathering detailed insights and metrics for @kant2002/prompt-sync
Gathering detailed insights and metrics for @kant2002/prompt-sync
Gathering detailed insights and metrics for @kant2002/prompt-sync
npm install @kant2002/prompt-sync
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
222 Stars
60 Commits
42 Forks
8 Watchers
2 Branches
9 Contributors
Updated on May 17, 2025
Latest Version
4.2.0
Package Id
@kant2002/prompt-sync@4.2.0
Unpacked Size
14.68 kB
Size
5.11 kB
File Count
5
NPM Version
9.2.0
Node Version
19.4.0
Published on
Mar 28, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
1
A sync prompt for node. very simple. no C++ bindings and no bash scripts.
Works on Linux, OS X and Windows.
1 2var prompt = require('prompt-sync')(); 3// 4// get input from the user. 5// 6var n = prompt('How many more times? ');
History is an optional extra, to use simply install the history plugin.
1npm install --save prompt-sync-history
1var prompt = require('prompt-sync')({ 2 history: require('prompt-sync-history')() //open history file 3}); 4//get some user input 5var input = prompt() 6prompt.history.save() //save history back to file
See the prompt-sync-history module for options, or fork it for customized behaviour.
require('prompt-sync')(config) => prompt
Returns an instance of the prompt
function.
Takes config
option with the following possible properties
sigint
: Default is false
. A ^C may be pressed during the input process to abort the text entry. If sigint it false
, prompt returns null
. If sigint is true
the ^C will be handled in the traditional way: as a SIGINT signal causing process to exit with code 130.
eot
: Default is false
. A ^D pressed as the first character of an input line causes prompt-sync to echo exit
and exit the process with code 0.
autocomplete
: A completer function that will be called when user enters TAB to allow for autocomplete. It takes a string as an argument an returns an array of strings that are possible matches for completion. An empty array is returned if there are no matches.
history
: Takes an object that supplies a "history interface", see prompt-sync-history for an example.
encoding
: Default is utf-8
. On Windows used for decoding of non-ASCII characters. For Cyrillic specify windows-1251
for example.
prompt(ask, value, opts)
ask
is the label of the prompt, value
is the default value
in absence of a response.
The opts
argument can also be in the first or second parameter position.
Opts can have the following properties
echo
: Default is '*'
. If set the password will be masked with the specified character. For hidden input, set echo to ''
(or use prompt.hide
).
autocomplete
: Overrides the instance autocomplete
function to allow for custom
autocompletion of a particular prompt.
value
: Same as the value
parameter, the default value for the prompt. If opts
is in the third position, this property will not overwrite the value
parameter.
ask
: Sames as the value
parameter. The prompt label. If opts
is not in the first position, the ask
parameter will not be overridden by this property.
prompt.hide(ask)
Convenience method for creating a standard hidden password prompt,
this is the same as prompt(ask, {echo: ''})
Line editing is enabled in the non-hidden mode. (use up/down arrows for history and backspace and left/right arrows for editing)
History is not set when using hidden mode.
1 //basic: 2 console.log(require('prompt-sync')()('tell me something about yourself: ')) 3 4 var prompt = require('prompt-sync')({ 5 history: require('prompt-sync-history')(), 6 autocomplete: complete(['hello1234', 'he', 'hello', 'hello12', 'hello123456']), 7 sigint: false 8 }); 9 10 var value = 'frank'; 11 var name = prompt('enter name: ', value); 12 console.log('enter echo * password'); 13 var pw = prompt({echo: '*'}); 14 var pwb = prompt('enter hidden password (or don\'t): ', {echo: '', value: '*pwb default*'}) 15 var pwc = prompt.hide('enter another hidden password: ') 16 var autocompleteTest = prompt('custom autocomplete: ', { 17 autocomplete: complete(['bye1234', 'by', 'bye12', 'bye123456']) 18 }); 19 20 prompt.history.save(); 21 22 console.log('\nName: %s\nPassword *: %s\nHidden password: %s\nAnother Hidden password: %s', name, pw, pwb, pwc); 23 console.log('autocomplete2: ', autocompleteTest); 24 25 function complete(commands) { 26 return function (str) { 27 var i; 28 var ret = []; 29 for (i=0; i< commands.length; i++) { 30 if (commands[i].indexOf(str) == 0) 31 ret.push(commands[i]); 32 } 33 return ret; 34 }; 35 };
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 6/21 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More