(arr: Uint8Array)
| 52 | } |
| 53 | |
| 54 | export function incrementRandom(arr: Uint8Array): void { |
| 55 | for (let i = idLength - 1; i >= epochLength; i--) { |
| 56 | if (arr[i]! < 255) { |
| 57 | arr[i]!++ |
| 58 | return |
| 59 | } |
| 60 | arr[i] = 0 |
| 61 | } |
| 62 | throw new Error('max random reached') |
| 63 | } |
| 64 | |
| 65 | // inspired by https://github.com/ryan-mars/ulid-workers/blob/06689d9ddd894bfc608c6131f9bbd2a8b48bcbc8/src/ulid.ts#L147 |
| 66 | export function idFactory() { |
no outgoing calls
no test coverage detected