aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/random.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/random.ts')
-rw-r--r--src/lib/random.ts28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/lib/random.ts b/src/lib/random.ts
index 4c8dbda3..73afa443 100644
--- a/src/lib/random.ts
+++ b/src/lib/random.ts
@@ -1,15 +1,17 @@
-import { NumberDictionary, animals, colors, uniqueNamesGenerator } from "unique-names-generator";
+const animals = [
+ "alligator", "bear", "cat", "dog", "eagle", "falcon", "gorilla", "hawk",
+ "iguana", "jaguar", "koala", "lion", "moose", "newt", "otter", "penguin",
+ "quail", "rabbit", "shark", "tiger", "urchin", "viper", "walrus", "fox",
+ "yak", "zebra", "badger", "crane", "dolphin", "elk",
+];
-export const randomName = () =>
- uniqueNamesGenerator({
- dictionaries: [animals, NumberDictionary.generate({ min: 10, max: 99 })],
- length: 2,
- separator: "",
- });
+const colors = [
+ "red", "blue", "green", "gold", "silver", "coral", "amber", "violet",
+ "teal", "crimson", "ivory", "jade", "navy", "olive", "scarlet",
+];
-export const randomPassword = () =>
- uniqueNamesGenerator({
- dictionaries: [colors, NumberDictionary.generate({ min: 100, max: 999 })],
- length: 2,
- separator: "",
- });
+const pick = (arr: string[]) => arr[Math.floor(Math.random() * arr.length)];
+const randInt = (min: number, max: number) => min + Math.floor(Math.random() * (max - min + 1));
+
+export const randomName = () => pick(animals) + randInt(10, 99);
+export const randomPassword = () => pick(colors) + randInt(100, 999);