Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(random module): add search terms and popular use cases #225

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/random/draw.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
10 changes: 10 additions & 0 deletions docs/random/random.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
10 changes: 10 additions & 0 deletions docs/random/shuffle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
10 changes: 10 additions & 0 deletions docs/random/uid.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Loading