(length: number)
| 16 | } |
| 17 | |
| 18 | function randomBase62(length: number): string { |
| 19 | const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" |
| 20 | let result = "" |
| 21 | const bytes = randomBytes(length) |
| 22 | for (let i = 0; i < length; i++) { |
| 23 | result += chars[bytes[i] % 62] |
| 24 | } |
| 25 | return result |
| 26 | } |
| 27 | |
| 28 | export function create(descending: boolean, timestamp?: number): string { |
| 29 | const currentTimestamp = timestamp ?? Date.now() |