| 72 | |
| 73 | // Generate ID functions |
| 74 | export function generateIdSeed() { |
| 75 | const pid = Math.floor(Math.random() * 32767).toString(16); |
| 76 | const machine = Math.floor(Math.random() * 16777216).toString(16); |
| 77 | const timestamp = Math.floor(new Date().valueOf() / 1000).toString(16); |
| 78 | return ( |
| 79 | "00000000".substr(0, 8 - timestamp.length) + |
| 80 | timestamp + |
| 81 | "000000".substr(0, 6 - machine.length) + |
| 82 | machine + |
| 83 | "0000".substr(0, 4 - pid.length) + |
| 84 | pid |
| 85 | ); |
| 86 | } |
| 87 | |
| 88 | export function generateId() { |
| 89 | return generateIdSeed() + "000001"; |