chore: change generateID()
implementation
This commit is contained in:
parent
bcd650e844
commit
f9175e98b9
1 changed files with 3 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Generate a pseudo-unique identifier (4 chars long)
|
* Generate a pseudo-unique identifier (5 chars long, mixed-case alphanumeric)
|
||||||
*
|
*
|
||||||
* Using uppercase + lowercase + digits, here's the collision risk:
|
* Here's the collision risk:
|
||||||
* - for 6 chars, 1 in 100 000
|
* - for 6 chars, 1 in 100 000
|
||||||
* - for 5 chars, 5 in 100 000
|
* - for 5 chars, 5 in 100 000
|
||||||
* - for 4 chars, 500 in 100 000
|
* - for 4 chars, 500 in 100 000
|
||||||
|
@ -9,5 +9,5 @@
|
||||||
* @returns string
|
* @returns string
|
||||||
*/
|
*/
|
||||||
export function generateId() {
|
export function generateId() {
|
||||||
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)
|
return btoa(Math.random().toString()).substring(10, 15)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue