Ids
Path:
_archive/loom-stale-pre-sprint-snapshot/src/lib/ids.tsRelative: loom-stale-pre-sprint-snapshot/src/lib/ids.tsSubproject: _archiveCategory: archivedLines: 58Bytes: 2,060Imports: 0Exports: 8
Content Preview
- /**
- * Identity + hashing primitives shared by every loop.
- * Web Crypto only — identical behavior on workerd and Bun (HC-1 parity).
- */
- const ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789";
- const ID_LEN = 12;
- function randomBody(): string {
- const bytes = new Uint8Array(ID_LEN);
- crypto.getRandomValues(bytes);
- let out = "";
- for (const b of bytes) out += ALPHABET[b % ALPHABET.length];
- return out;
- }
- export const newGoalId = (): `goal_${string}` => `goal_${randomBody()}`;
- export cons