mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-30 06:29:23 +02:00
18 lines
629 B
TypeScript
18 lines
629 B
TypeScript
|
import { fileURLToPath } from 'url';
|
||
|
import { dirname, join } from 'path';
|
||
|
import { readFileSync } from 'fs';
|
||
|
|
||
|
// Get the directory name of the current module
|
||
|
const __filename = fileURLToPath(import.meta.url);
|
||
|
const __dirname = dirname(__filename);
|
||
|
|
||
|
// Load the names from the names.json file
|
||
|
const file = join(__dirname, 'names.json');
|
||
|
export const names = JSON.parse(readFileSync(file, 'utf-8'));
|
||
|
|
||
|
export function getUniqueName(): string {
|
||
|
return (
|
||
|
names.animals[Math.floor(Math.random() * names.animals.length)] +
|
||
|
names.descriptor[Math.floor(Math.random() * names.descriptor.length)]
|
||
|
).toLowerCase();
|
||
|
}
|