@storm-stack/unique-identifier
Version:
This package provides a simple way to generate various types of unique identifiers.
7 lines (6 loc) • 314 B
JavaScript
const alphabet = Array.from(
{ length: 26 },
(_x, i) => String.fromCodePoint(i + 97)
);
export const randomInteger = (maximum, minimum = 0) => Math.floor(Math.random() * (maximum - minimum + 1) + minimum);
export const randomLetter = (random = Math.random) => alphabet[Math.floor(random() * alphabet.length)];