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 🙏

© 2025 – Pkg Stats / Ryan Hefner

random-utils-and-tools

v1.0.8

Published

Random tools

Readme

Installation

npm i random-utils-and-tools

Get started

let random = new (require('random-utils-and-tools').Random)()

Usage

// Constants  
let digits          = random.digits; // Digits 0-9  
let specials        = random.specials; // Special characters  
let ascii_lowercase = random.ascii_lowercase; // Lowercase alphabet  
let ascii_uppercase = random.ascii_uppercase; // Uppercase alphabet  
let ascii_letters   = random.ascii_letters // Both lowercase and uppercase letters  
  

// Range
random.range(1, 100) 
// [1, 2, 3, ..., 99]

random.range(100) // return all integers between 0-99 
// [0, 1, 2, 3, ..., 99]

random.range(1, 100, 2) // returns all odd numbers between 1-100
// [1, 3, 5, 7, ..., 97, 99]

random.range(100, 1, -1) // return range 2-100 reversed
// [100, 99, 98, ..., 3, 2]

random.range(100, 1, -5)
// [100, 95, 90, ..., 10, 5]


  

// Random integer  
random.int(1, 10) // Random integer in range 1-10  
random.int(5) // Random integer in range 0-5  
  
  
// Random float  
random.float(1, 2) // Random float in range 1-2  
random.float(5) // Random float in range 0-5  
random.float() // Random float in range 0-1  
  
  
// Random boolean  
random.boolean() // true or false  
  
  
// Others  
random.randomAsciiLetters(length = 10) // Random 10 ascii letters as string  
random.randomSpecials(length = 10) // Random 10 special characters as string  
random.randomDigits(length = 10) // Random 10 digits as string  
random.randomAsciiLowercase(length = 10) // Random 10 lowercase ascii letters as string  
random.randomAsciiUppercase(length = 10) // Random 10 uppercase ascii letters as string  
  
  
  
// Random element from collection (string, array, etc.)  
random.choice([99, 42, 58, 19, 52]);  
random.choice("Hello, world");  
  
// Also can take few arguments  
random.choice(  
    [1, 2, 3, 4, 5],  
  "Hello, world"  
) // Chooses between each elements of all arguments  
  
  
  
// Few random elements from collection (Elements can repeat)  
random.chooseFew(  
    arr = [42, 94, 29, 10, 40], // Array  
  count = 3 // Choices count  
)  
  
// Few random elements without repeating elements  
random.chooseFew(  
    arr = [92, 58, 29, 104, 285, 10], // Array  
  count = 3, // Choice count,  
  repeat = false // Default is true so there can be repeating elements  
)  
// If repeat is false then count should be lesser or equal to arr.length  
  
  
  
// Random count of random elements from collection with no repeating items
random.chooseAny(  
    arr = [49, 4290, 63, 99, 29],  
  repeat = false,  
  limit = 2  
)  
// Limit is the maximum possible length of list the method returns  
// If repeat is true (default value), then limit can be any integer  
// If repeat is false, then limit must be between 0, arr.length



// Randomly shuffle list
random.shuffle(
    [1, 2, 3, 4, 5]
)

// Also takes few parameters and returns one list with all parameters together
random.shuffle(
    [1, 2, 3, 4, 5],
    "Hello, world",
[6, 7, 8, 9, 10]
)



// Get randomly shuffled list of numbers in range
random.randomRange(1, 100) // Is equal to random.shuffle(random.range(1, 100))
random.randomRange(100, 1, -1) // = random.shuffle(random.range(100, 1, -1))
random.randomRange(1000) // = random.shuffle(random.range(1000))