tickle/modules/utils/getRandomId.mjs
2023-06-07 22:07:47 +02:00

14 lines
347 B
JavaScript

//@ts-check
/**
* short random string for ids - not guaranteed to be unique
* @see https://www.codemzy.com/blog/random-unique-id-javascript
* @param {number} length the length of the id
*/
export const getRandomId = function (length = 6) {
return Math.random()
.toString(36)
.substring(2, length + 2);
};
export default getRandomId