diff --git a/docs/random/draw.mdx b/docs/random/draw.mdx index a2b12cdf..64c91d12 100644 --- a/docs/random/draw.mdx +++ b/docs/random/draw.mdx @@ -14,3 +14,13 @@ const fish = ['marlin', 'bass', 'trout'] _.draw(fish) // => a random fish ``` + +### Search terms + +- Often called `pickRandom`, `chooseRandom`, or `randomItem`. + +### Popular use cases + +- Selecting a random item from a non-mutated array, useful for implementing random selection in games, lotteries, or sampling data. +- Drawing random options from predefined lists like quiz answers or promotional offers without altering the original dataset. +- Safely handling empty arrays by returning `null`, preventing errors or undefined behavior when trying to draw from an empty list. diff --git a/docs/random/random.mdx b/docs/random/random.mdx index 20de0dae..491a6024 100644 --- a/docs/random/random.mdx +++ b/docs/random/random.mdx @@ -12,3 +12,13 @@ import * as _ from 'radashi' _.random(0, 100) // => a random number between 0 and 100 ``` + +### Search terms + +- Often called `randomInt`, `randomBetween`, or `generateRandomNumber`. + +### Popular use cases + +- Generating random numbers within a defined range for use in simulations, gaming logic, or random sampling scenarios. +- Creating randomized values for testing purposes, ensuring coverage of edge cases by varying inputs across test runs. +- Implementing randomness in user interfaces, such as displaying random quotes, images, or product suggestions in e-commerce applications. diff --git a/docs/random/shuffle.mdx b/docs/random/shuffle.mdx index 46d8cd30..db87d30e 100644 --- a/docs/random/shuffle.mdx +++ b/docs/random/shuffle.mdx @@ -30,3 +30,13 @@ const fish = [ _.shuffle(fish) ``` + +### Search terms + +- Often called `randomizeArray`, `shuffleArray`, or `scrambleItems`. + +### Popular use cases + +- Creating a randomized version of an array without modifying the original, perfect for scenarios like shuffling cards in a game or presenting items in a random order. +- Generating random permutations of datasets for testing or data analysis, ensuring unbiased sampling and unique configurations. +- Implementing randomized displays of content such as lists of products, images, or content in dynamic user interfaces. diff --git a/docs/random/uid.mdx b/docs/random/uid.mdx index fc81f468..43d420c1 100644 --- a/docs/random/uid.mdx +++ b/docs/random/uid.mdx @@ -15,3 +15,13 @@ _.uid(12, '*') // => egFn*THGelM8 ``` Note, this function is optimized for simplicity and usability -- not performance or security. If you need to create universally unique or cryptographically random strings use a package specifically for that purpose. + +### Search terms + +- Often called `generateUID` or `randomString`. + +### Popular use cases + +- Generating unique identifiers for temporary data, such as session tokens, verification codes, or random usernames. +- Creating randomized strings with custom special characters, useful for password generation or secure key creation. +- Producing random strings of a specific length for use in tests, security, or as placeholders in development environments.