UNPKG

@storm-stack/unique-identifier

Version:

This package provides a simple way to generate various types of unique identifiers.

13 lines (12 loc) 506 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.randomLetter = exports.randomInteger = void 0; const alphabet = Array.from({ length: 26 }, (_x, i) => String.fromCodePoint(i + 97)); const randomInteger = (maximum, minimum = 0) => Math.floor(Math.random() * (maximum - minimum + 1) + minimum); exports.randomInteger = randomInteger; const randomLetter = (random = Math.random) => alphabet[Math.floor(random() * alphabet.length)]; exports.randomLetter = randomLetter;