
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
random-utils-and-tools
Advanced tools
npm i random-utils-and-tools
let random = new (require('random-utils-and-tools').Random)()
// 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))
FAQs
Random tools
We found that random-utils-and-tools demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.