Socket
Socket
Sign inDemoInstall

promptly

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promptly

Simple command line prompting utility


Version published
Weekly downloads
1.5M
decreased by-0.68%
Maintainers
2
Weekly downloads
 
Created

What is promptly?

The 'promptly' npm package is a simple utility for prompting user input in Node.js applications. It provides a straightforward way to ask for user input from the command line, with support for validation, default values, and hidden input for sensitive information.

What are promptly's main functionalities?

Basic Prompt

This feature allows you to prompt the user for input and then use that input in your application. The example code asks the user for their name and then greets them.

const promptly = require('promptly');

(async () => {
  const name = await promptly.prompt('Enter your name: ');
  console.log(`Hello, ${name}!`);
})();

Prompt with Default Value

This feature allows you to provide a default value for the prompt. If the user does not enter anything, the default value will be used. The example code sets 'Anonymous' as the default name.

const promptly = require('promptly');

(async () => {
  const name = await promptly.prompt('Enter your name: ', { default: 'Anonymous' });
  console.log(`Hello, ${name}!`);
})();

Hidden Input

This feature allows you to prompt the user for input without displaying what they type on the screen. This is useful for sensitive information like passwords. The example code asks for a password and hides the input.

const promptly = require('promptly');

(async () => {
  const password = await promptly.prompt('Enter your password: ', { silent: true });
  console.log('Password received.');
})();

Input Validation

This feature allows you to validate the user's input before accepting it. The example code validates that the input is a positive integer representing the user's age.

const promptly = require('promptly');

(async () => {
  const age = await promptly.prompt('Enter your age: ', {
    validator: (value) => {
      const age = parseInt(value, 10);
      if (isNaN(age) || age <= 0) {
        throw new Error('Invalid age');
      }
      return age;
    }
  });
  console.log(`You are ${age} years old.`);
})();

Other packages similar to promptly

Keywords

FAQs

Package last updated on 29 Jan 2015

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc