Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

inquirer-checkbox-plus-prompt

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inquirer-checkbox-plus-prompt

Checkbox with autocomplete and other additions for Inquirer

  • 1.4.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4M
increased by3.9%
Maintainers
1
Weekly downloads
 
Created

What is inquirer-checkbox-plus-prompt?

The inquirer-checkbox-plus-prompt package is an extension for the Inquirer.js library that provides a checkbox prompt with autocompletion. It allows users to select multiple options from a list with the added functionality of filtering options through a search input.

What are inquirer-checkbox-plus-prompt's main functionalities?

Basic Checkbox Prompt with Autocomplete

This feature allows users to select multiple options from a list with the ability to filter the options by typing in a search input. The code demonstrates how to set up a basic checkbox prompt with autocomplete functionality.

const inquirer = require('inquirer');
const CheckboxPlusPrompt = require('inquirer-checkbox-plus-prompt');
inquirer.registerPrompt('checkbox-plus', CheckboxPlusPrompt);

inquirer.prompt([
  {
    type: 'checkbox-plus',
    name: 'fruits',
    message: 'Select your favorite fruits',
    choices: ['Apple', 'Orange', 'Banana', 'Grapes', 'Pineapple'],
    pageSize: 10,
    source: (answersSoFar, input) => {
      input = input || '';
      return new Promise((resolve) => {
        const choices = ['Apple', 'Orange', 'Banana', 'Grapes', 'Pineapple'];
        const filteredChoices = choices.filter(choice => choice.toLowerCase().includes(input.toLowerCase()));
        resolve(filteredChoices);
      });
    }
  }
]).then(answers => console.log(answers));

Dynamic Choices Loading

This feature demonstrates how to load choices dynamically, simulating an asynchronous call to fetch data. The user can filter the list of countries by typing in the search input.

const inquirer = require('inquirer');
const CheckboxPlusPrompt = require('inquirer-checkbox-plus-prompt');
inquirer.registerPrompt('checkbox-plus', CheckboxPlusPrompt);

inquirer.prompt([
  {
    type: 'checkbox-plus',
    name: 'countries',
    message: 'Select countries you have visited',
    pageSize: 10,
    source: (answersSoFar, input) => {
      input = input || '';
      return new Promise((resolve) => {
        // Simulate an asynchronous call to fetch data
        setTimeout(() => {
          const allCountries = ['USA', 'Canada', 'Mexico', 'Germany', 'France', 'Italy', 'Spain', 'China', 'Japan', 'Australia'];
          const filteredCountries = allCountries.filter(country => country.toLowerCase().includes(input.toLowerCase()));
          resolve(filteredCountries);
        }, 1000);
      });
    }
  }
]).then(answers => console.log(answers));

Other packages similar to inquirer-checkbox-plus-prompt

Keywords

FAQs

Package last updated on 23 Jan 2023

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