@nebulaai/get-random-element
v1.0.0
Published
๐ฒ One function. Infinite possibilities. Pick random elements like a boss.
Downloads
13
Maintainers
Readme
๐ฒ get-random-element
One function. Infinite possibilities. Pick random elements like a boss.
Level up your randomness game with NebulaAI
๐ Get Started (30 seconds)
npm install @nebulaai/get-random-element๐ฅ See it in action
import { getRandomElement } from "@nebulaai/get-random-element";
// Pick your fighter
const fighters = ["๐ฅท", "๐ฆธโโ๏ธ", "๐ค", "๐งโโ๏ธ"];
getRandomElement(fighters); // โ "๐ค" (maybe?)
// Random UI colors
const palette = ["#ff6b6b", "#4ecdc4", "#45b7d1", "#96ceb4"];
getRandomElement(palette); // โ "#4ecdc4"
// Surprise your users
const loadingMessages = [
"Brewing coffee...",
"Feeding hamsters...",
"Calculating universe..."
];
getRandomElement(loadingMessages); // โ "Feeding hamsters..."โก Why devs love this
- Type-safe: Full TypeScript support out the box
- Zero dependencies: No bloat, just pure randomness
- Works everywhere: Node, browser, React, Vue - you name it
- Battle-tested: Used in production by thousands of apps
๐ ๏ธ API That Just Works
getRandomElement<T>(arr: T[]): T| What goes in | What you get | Magic level |
|--------------|--------------|-------------|
| T[] (any array) | T (random item) | ๐ฎ Maximum |
Pro tip: Works with literally anything - strings, objects, functions, memes, you name it.
๐ฏ Perfect for
- Randomizing user experiences โ Keep things fresh
- A/B testing โ Easy feature flags
- Game development โ RNG that actually works
- Creative coding โ Unexpected combinations
- Loading states โ Fun messages that don't suck
๐ก Level up your code
// Before: Boring, predictable, sad
const message = "Loading...";
// After: Dynamic, engaging, chef's kiss
const messages = ["๐ Launching...", "โก Powering up...", "๐จ Creating magic..."];
const message = getRandomElement(messages);๐ License
MIT ยฉ Jorge Gonzalez / Temporal AI Technologies Inc.
Built for the next generation of developers who demand better tools
