1.0.2 • Published 2 years ago
@dosiichuk/unique-identifiers v1.0.2
Unique identifiers
This package serves for generating unique identifiers of fixed length provided as an argument to the exported function randomId
License
This package is available under MIT license
const randomID = (idLength) => {
let id = '';
const characters =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const charsAmount = characters.length;
for (let i = 0; i < idLength; i++) {
id += characters.charAt(Math.floor(Math.random() * charsAmount));
}
console.log(id);
return id;
};