Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 22x 22x 22x 32x 32x 22x 32x 22x | import identifier from './identifier.js'
import type Sid from './sanitised-identifier.js'
const alphabet = 'abcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXYZ'
const randomLetter =
(): string => {
const index = Math.min(alphabet.length - 1, Math.floor(Math.random() * alphabet.length))
return alphabet[index]
}
const randomIdentifier =
(prefix = '', length = 32): Sid =>
identifier([ prefix, Array.from(Array(length), () => randomLetter()).join('') ].join(''))
export default randomIdentifier
|