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

@deadapi/input

v1.0.0

Published

A flexible input gathering and validation utility for Node.js. Supports multiple data types, including strings, numbers, arrays, and tuples, with both synchronous and asynchronous modes.

Downloads

5

Readme

@deadapi/input

A flexible input gathering and validation utility for Node.js. Supports multiple data types, including strings, numbers, arrays, tuples, and more, with both synchronous and asynchronous modes.

Installation

To install the @deadapi/input package, use npm:

npm install @deadapi/input

Usage

Basic Examples

String Input:

const { input } = require('@deadapi/input');
const name = input("&str", "Enter your name:");
console.log("Your name is:", name);

Integer Input with Default:

const age = input("&int", "Enter your age:", { defaultValue: "25" });
console.log("Your age is:", age);

Intermediate Examples

Array of Numbers:

const numbers = input("&array:num", "Enter numbers (comma-separated):", { defaultValue: "1.1,2.2,3.3" });
console.log("Your number array is:", numbers);

Boolean Input:

const isConfirmed = input("&bool", "Are you sure? (true/false):", { defaultValue: "true" });
console.log("Confirmation:", isConfirmed);

Advanced Examples

Tuple with Mixed Types:

const userInfo = input("&tuple:str|int|bool", "Enter info (comma-separated, e.g., Name, Age, IsMember):", { defaultValue: "John Doe,30,true" });
console.log("User Information:", userInfo);

Asynchronous Input:

const runAsyncExample = async () => {
const result = await input("&str", "Enter input asynchronously:", { defaultValue: "Async Default", isAsync: true });
console.log("Your async result is:", result);
};
runAsyncExample();

Input Types

  • &str: String
  • &int: Integer
  • &float: Float
  • &num: Number (float or int)
  • &bool: Boolean
  • &date: Date
  • &array:type: Array of specified type (e.g., &array:int)
  • &tuple:type|type|...: Tuple with specified types (e.g., &tuple:str|int|bool)
  • &ip: IP Address
  • &url: URL
  • &email: Email
  • &uuid: UUID
  • &hexColor: Hex Color Code
  • &creditCard: Credit Card Number (use responsibly, for valid purposes only)

Disclaimer for Credit Card Input

The &creditCard type is provided for educational purposes and should only be used for legitimate and secure handling of credit card information. The package author is not responsible for any misuse or consequences related to the use of this feature. Ensure compliance with relevant regulations and standards when handling sensitive information.

Contributing

Contributions are welcome! Fork the repository, create a feature branch, make your changes, and open a pull request.

License

Licensed under the MIT License.