1 | //
|
2 |
|
3 | let idCounter = 0;
|
4 |
|
5 | module.exports = () => {
|
6 | const normalizedDateString = Date.now().toString(36).padStart(9, '0');
|
7 | const idCounterString = idCounter.toString(36).padStart(4, '0');
|
8 | const randomString = Math.round(Number.MAX_SAFE_INTEGER / 2 + Number.MAX_SAFE_INTEGER * Math.random() / 2).toString(36);
|
9 | const id = (`${normalizedDateString}${idCounterString}${randomString}`).slice(0, 16);
|
10 | idCounter += 1;
|
11 | if (idCounter > 1679615) {
|
12 | idCounter = 0;
|
13 | }
|
14 | return id;
|
15 | };
|