Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@types/prompts
Advanced tools
@types/prompts provides TypeScript type definitions for the 'prompts' library, which is used to create interactive command-line prompts.
Basic Text Prompt
This feature allows you to create a basic text prompt where the user can input a string. The example asks for the user's name and then greets them.
const prompts = require('prompts');
(async () => {
const response = await prompts({
type: 'text',
name: 'value',
message: 'What is your name?'
});
console.log(`Hello, ${response.value}!`);
})();
Select Prompt
This feature allows you to create a select prompt where the user can choose from a list of options. The example lets the user pick a color from a list.
const prompts = require('prompts');
(async () => {
const response = await prompts({
type: 'select',
name: 'color',
message: 'Pick a color',
choices: [
{ title: 'Red', value: 'red' },
{ title: 'Green', value: 'green' },
{ title: 'Blue', value: 'blue' }
],
initial: 1
});
console.log(`You chose: ${response.color}`);
})();
Confirm Prompt
This feature allows you to create a confirm prompt where the user can answer with a yes or no. The example asks if the user wants to continue and logs the response.
const prompts = require('prompts');
(async () => {
const response = await prompts({
type: 'confirm',
name: 'value',
message: 'Do you want to continue?'
});
console.log(response.value ? 'Continuing...' : 'Aborted');
})();
Inquirer.js is a collection of common interactive command-line user interfaces. It provides similar functionalities to 'prompts' but with a more extensive set of features and customization options.
Enquirer is a stylish, intuitive, and user-friendly prompt system for Node.js. It offers similar functionalities to 'prompts' but focuses more on customization and user experience.
Vorpal is a framework for building interactive CLI applications. It provides similar prompt functionalities but also includes features for building more complex command-line interfaces.
npm install --save @types/prompts
This package contains type definitions for prompts (https://github.com/terkelg/prompts).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/prompts
Additional Details
These definitions were written by Berkay GURSOY https://github.com/Berkays, Daniel Perez Alvarez https://github.com/danielpa9708, Kamontat Chantrachirathumrong https://github.com/kamontat, and theweirdone https://github.com/theweirdone.
FAQs
TypeScript definitions for prompts
The npm package @types/prompts receives a total of 349,931 weekly downloads. As such, @types/prompts popularity was classified as popular.
We found that @types/prompts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.