From 68684395a080a834d823b39e2e9641372bbafbfd Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 2 Mar 2026 23:37:57 -0800 Subject: dependency audit --- src/lib/random.ts | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src/lib/random.ts') 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); -- cgit v1.2.3