0.1.0 • Published 5 months ago
prompt-mini v0.1.0
prompt-mini
A lightweight, zero-dependency Node.js package for handling command-line prompts and password inputs.
Features
- 🪶 Lightweight with zero dependencies
- 🔒 Secure password input with customizable masking
- ⌨️ Simple text input prompts
- 🎯 TypeScript support
- ⚡ Promise-based API
Installation
npm install prompt-mini
Usage
Basic Input Prompt
import { question } from "prompt-mini";
const name = await question("What is your name? ");
console.log(`Hello, ${name}!`);
Password Prompt
import { passwordPrompt } from "prompt-mini";
// Default masking with ''
const password = await passwordPrompt("Enter your password: ");
// Custom masking character
const pin = await passwordPrompt("Enter PIN: ", { mask: "•" });
API Reference
question(query: string): Promise
Prompts the user for text input.
query
: The prompt message to display- Returns: Promise resolving to the user's input
passwordPrompt(query: string, options?: PasswordPromptOptions): Promise
Securely prompts for password input with masked characters.
Options:
mask
: Character used to mask the input (default: '*')
Features:
- Masked input
- Handles backspace
- Ctrl+C support
- Secure input handling
Security
Password input is handled securely by:
- Not echoing characters to the terminal
- Using raw mode for input processing
- Proper cleanup of event listeners
- Memory cleanup after input completion
License
Apache License 2.0 - See LICENSE for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
Issues
If you find any bugs or have feature requests, please create an issue on the GitHub repository.
0.1.0
5 months ago