@corentinth/friendly-ids
Version:
A human friendly ID generator
597 lines (593 loc) • 7.74 kB
JavaScript
const adjectives = [
"adaptable",
"adventurous",
"affable",
"affectionate",
"afraid",
"aged",
"agreeable",
"all",
"ambitious",
"ambivalent",
"amiable",
"amicable",
"amusing",
"ancient",
"angry",
"angular",
"anonymous",
"arcane",
"arguable",
"armored",
"artistic",
"aspiring",
"astute",
"atmospheric",
"audacious",
"austere",
"authoritative",
"average",
"bad",
"baffling",
"bald",
"banal",
"bare",
"basic",
"beaming",
"beige",
"bewildering",
"big",
"bigoted",
"bitter",
"bittersweet",
"black",
"blissful",
"blue",
"blunt",
"boastful",
"bold",
"bony",
"bookish",
"bouncy",
"brash",
"brave",
"brazen",
"breezy",
"brief",
"bright",
"brooding",
"brown",
"bubbly",
"buckled",
"buff",
"bumpy",
"burdened",
"busy",
"cacophonous",
"calm",
"careful",
"cautious",
"celebratory",
"chaotic",
"charming",
"chatty",
"cheeky",
"chilly",
"chubby",
"clean",
"clear",
"clever",
"clumsy",
"coarse",
"cold",
"colossal",
"comical",
"common",
"communal",
"communicative",
"compassionate",
"complex",
"confident",
"conscientious",
"considerate",
"convivial",
"cool",
"courageous",
"courteous",
"cowardly",
"crazy",
"creative",
"cruel",
"cuddly",
"curly",
"curvy",
"cute",
"cyan",
"dangerous",
"dark",
"decisive",
"deep",
"delicate",
"determined",
"diligent",
"diplomatic",
"dirty",
"discreet",
"divine",
"dry",
"dull",
"dynamic",
"eager",
"early",
"easy",
"easygoing",
"emotional",
"empty",
"energetic",
"enthusiastic",
"every",
"evil",
"exuberant",
"fair",
"faithful",
"famous",
"fancy",
"fast",
"fat",
"fearless",
"few",
"fine",
"flat",
"floppy",
"floral",
"fluffy",
"foolish",
"forceful",
"frank",
"free",
"fresh",
"friendly",
"fruity",
"full",
"funny",
"fuzzy",
"generous",
"gentle",
"giant",
"gold",
"good",
"great",
"green",
"gregarious",
"grumpy",
"happy",
"hard",
"heavy",
"helpful",
"helpless",
"hidden",
"hip",
"holy",
"honest",
"horrible",
"hot",
"huge",
"humorous",
"hungry",
"icy",
"imaginative",
"impartial",
"independent",
"intellectual",
"intelligent",
"intuitive",
"inventive",
"itchy",
"jolly",
"khaki",
"kind",
"large",
"late",
"lazy",
"legal",
"lemon",
"light",
"little",
"lively",
"long",
"loose",
"loud",
"lovely",
"loving",
"loyal",
"lucky",
"major",
"many",
"massive",
"mean",
"metal",
"mighty",
"misty",
"modern",
"modest",
"moody",
"nameless",
"nasty",
"neat",
"nervous",
"new",
"nice",
"odd",
"old",
"olive",
"open",
"optimistic",
"orange",
"ordinary",
"passionate",
"patient",
"perfect",
"persistent",
"petite",
"philosophical",
"pink",
"pioneering",
"placid",
"plain",
"plastic",
"plenty",
"plucky",
"polished",
"polite",
"poor",
"popular",
"powerful",
"practical",
"pretty",
"proud",
"public",
"puny",
"purple",
"quick",
"quiet",
"rare",
"rational",
"ready",
"real",
"red",
"reliable",
"reserved",
"resourceful",
"restless",
"rich",
"ripe",
"romantic",
"rotten",
"rude",
"sad",
"salty",
"selfish",
"sensible",
"sensitive",
"serious",
"shaggy",
"shaky",
"sharp",
"shiny",
"short",
"shy",
"silent",
"silly",
"silver",
"sincere",
"slick",
"slimy",
"slippery",
"slow",
"small",
"smart",
"smooth",
"snowy",
"sociable",
"social",
"soft",
"solid",
"some",
"sour",
"spicy",
"splendid",
"spotty",
"stale",
"still",
"straightforward",
"strange",
"strong",
"stupid",
"sweet",
"swift",
"sympathetic",
"tall",
"tame",
"tangy",
"tasty",
"tender",
"terrible",
"thick",
"thin",
"thoughtful",
"tidy",
"tiny",
"tired",
"tough",
"tricky",
"true",
"ugly",
"unassuming",
"understanding",
"unlucky",
"upset",
"vast",
"versatile",
"violet",
"wandering",
"warm",
"warmhearted",
"weak",
"wet",
"white",
"whole",
"wicked",
"wide",
"wild",
"willing",
"wise",
"withered",
"witty",
"wonderful",
"yellow",
"young",
"yummy"
];
const animals = [
"albatross",
"alligator",
"alpaca",
"ant",
"anteater",
"antelope",
"ape",
"armadillo",
"axolotl",
"baboon",
"badger",
"barracuda",
"bat",
"bear",
"beaver",
"bee",
"beluga",
"bird",
"bison",
"boar",
"bobcat",
"bonobo",
"bulldog",
"bullfrog",
"butterfly",
"camel",
"capybara",
"caribou",
"cassowary",
"cat",
"caterpillar",
"catfish",
"cheetah",
"chicken",
"chimpanzee",
"chinchilla",
"chipmunk",
"cobra",
"cockroach",
"cormorant",
"cougar",
"cow",
"coyote",
"crab",
"crane",
"crocodile",
"deer",
"dingo",
"dodo",
"dog",
"dolphin",
"donkey",
"dormouse",
"dove",
"dragon",
"dragonfly",
"duck",
"dugong",
"eagle",
"earwig",
"eel",
"egret",
"elephant",
"elk",
"emu",
"falcon",
"ferret",
"finch",
"fireant",
"firefly",
"firefox",
"fish",
"flamingo",
"fly",
"fox",
"frog",
"gazelle",
"gecko",
"gibbon",
"giraffe",
"goat",
"goldfish",
"goose",
"gorilla",
"grasshopper",
"hamster",
"hare",
"hawk",
"hedgehog",
"heron",
"hippopotamus",
"horse",
"hound",
"hummingbird",
"husky",
"hyena",
"ibex",
"ibis",
"impala",
"insect",
"jackal",
"jaguar",
"jellyfish",
"junco",
"kangaroo",
"kingfisher",
"koala",
"kookaburra",
"ladybug",
"lamprey",
"lemur",
"leopard",
"liger",
"lion",
"lionfish",
"lizard",
"lobster",
"loon",
"lynx",
"macaw",
"magpie",
"manatee",
"mandrill",
"mayfly",
"meerkat",
"mink",
"mole",
"monkey",
"moose",
"mosquito",
"moth",
"mouse",
"mule",
"narwhal",
"nautilus",
"newt",
"nightingale",
"octopus",
"okapi",
"opossum",
"orangutan",
"orca",
"ostrich",
"otter",
"owl",
"panda",
"panther",
"parrot",
"peacock",
"pelican",
"penguin",
"pheasant",
"pig",
"pigeon",
"platypus",
"porcupine",
"porpoise",
"possum",
"puffin",
"pug",
"puma",
"python",
"quail",
"quokka",
"quoll",
"rabbit",
"raccoon",
"ram",
"rat",
"rattlesnake",
"raven",
"ray",
"reindeer",
"rhinoceros",
"roadrunner",
"robin",
"salamander",
"salmon",
"sandpiper",
"sardine",
"scorpion",
"seahorse",
"seal",
"shark",
"sheep",
"shrimp",
"skunk",
"sloth",
"snail",
"snake",
"sparrow",
"spider",
"squid",
"squirrel",
"starfish",
"stingray",
"swan",
"tapir",
"termite",
"tiger",
"toad",
"toucan",
"treefrog",
"tuna",
"turkey",
"turtle",
"umbrellabird",
"urchin",
"vampirebat",
"viper",
"vulture",
"wallaby",
"walrus",
"warthog",
"wasp",
"weasel",
"whale",
"wolf",
"wolverine",
"wombat",
"woodpecker",
"worm",
"yak",
"yellowjacket",
"zebra",
"zebu"
];
function createIdGenerator({
getRandomInt = ({ min, max }) => Math.floor(Math.random() * (max - min)) + min,
separator = "-",
chunks = [
({ getRandomItem }) => getRandomItem(adjectives),
({ getRandomItem }) => getRandomItem(animals),
({ getRandomInt: getRandomInt2 }) => getRandomInt2({ min: 0, max: 1e3 })
]
} = {}) {
const getRandomItem = (items) => items[getRandomInt({ min: 0, max: items.length })];
return () => chunks.map((chunk) => chunk({ getRandomInt, getRandomItem })).join(separator);
}
const generateId = createIdGenerator();
export { adjectives, animals, createIdGenerator, generateId };
//# sourceMappingURL=index.mjs.map