npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@keg-hub/ask-it

v1.1.2

Published

Node CLI helper for asking questions

Downloads

1,864

Readme

AskIt

Wrapper around inquirer to make asking questions in Node CLIs easier.

Setup

Install It

Add to your package.json

  "askIt": "git+https://github.com/keg-hub/askIt.git"

Use It

See an example here

;(() => {

  const { ask, separator, models } = require('askIt')

  // See src/models/models for more information
  const questionModelObject = {
    // Add the default input model
    ...models.input,
    // Override with custom values
    type: 'Question type',
    name: 'Name of the question',
    message: 'Question to ask',
    default: 'Default value if user enters nothing',
  }

  // Pass the model directly to the ask method
  // Returns a value entered by the user or the default
  const askResponse = await ask({ ...questionModelObject })

  // Ask a true / false question
  // Returns a boolean
  const confirmResponse = await ask.confirm('Ask a confirm question?')

  // Ask for text input
  // Returns a string of the entered text
  const inputResponse = await ask.input('Ask for text input')
  
  // Ask for a password / secret - input will be hidden
  // Returns a string of the entered text
  const passwordResponse = await ask.password('Ask for hidden text input')

  // Ask for user to select an option from a list of options
  // Returns the index of the select option within the passed in array
  const listResponse = await ask.promptList([
    'Option 1',
    'Option 2',
    'Option 3',
  ])

})()

API

ask

  • @type function
  • @param Object - a question model object
  • ask.confirm
    • @type function
    • @param string - The true / false question to ask
    • Helper method to ask a true/false question
    • Accepts a string used as the question asked to the user
  • ask.input
    • @type function
    • @param string - The text input question to ask
    • Helper method to ask a text input question
  • ask.password
    • @type function
    • @param string - The text input question to ask
    • Same as ask.input, except user input is hidden
  • ask.promptList
    • @type function
    • @param array - List of options to present to the user
    • Asks the user to select from a list of options
    • @returns - index of the selected item from the passed in options

separator

  • @type function
  • Helper that returns new inquirer.Separator()

models

  • @type Object
  • Prebuilt question models with defaults already set
  • Expected to be overwritten with custom values as needed
  • Question model object