{"id":16594505,"url":"https://github.com/sverweij/uuid-compact","last_synced_at":"2025-07-01T13:03:25.066Z","repository":{"id":253688202,"uuid":"844225922","full_name":"sverweij/uuid-compact","owner":"sverweij","description":"Represent UUIDs with compact base64url encoding","archived":false,"fork":false,"pushed_at":"2024-11-22T20:08:19.000Z","size":62,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-06T17:25:02.905Z","etag":null,"topics":["compact","uuid"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sverweij.png","metadata":{"files":{"readme":"README-sample.ts","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-08-18T18:53:17.000Z","updated_at":"2024-11-22T20:08:23.000Z","dependencies_parsed_at":"2024-08-23T19:58:48.380Z","dependency_job_id":"d61a3cc2-f37f-457a-b9b2-e8886f9826c5","html_url":"https://github.com/sverweij/uuid-compact","commit_stats":null,"previous_names":["sverweij/uuid-compact"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sverweij/uuid-compact","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sverweij%2Fuuid-compact","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sverweij%2Fuuid-compact/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sverweij%2Fuuid-compact/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sverweij%2Fuuid-compact/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sverweij","download_url":"https://codeload.github.com/sverweij/uuid-compact/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sverweij%2Fuuid-compact/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262969808,"owners_count":23392526,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compact","uuid"],"created_at":"2024-10-11T23:46:28.344Z","updated_at":"2025-07-01T13:03:25.009Z","avatar_url":"https://github.com/sverweij.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"import {\n  toCompactUUID,\n  toCanonicalUUID,\n  isValidUUID,\n  isValidCompactUUID,\n} from \"uuid-compact\";\n// this package does not provide a way to generate UUID's, but you can use the\n// use e.g. the node:crypto module to generate UUIDv4's (which is what most\n// of us use anyway), or the 'uuid' package from npm to generate any of the other\n// variants from RFC4122.\nimport { randomUUID } from \"node:crypto\";\n\nconst lUUID = randomUUID();\nconsole.log(\"Original UUID :\", lUUID);\n// 1a664e13-ac6a-4365-937d-9e6e8193322e\n\nconst lCompactUUID = toCompactUUID(lUUID);\nconsole.log(\"Compacted UUID:\", lCompactUUID);\n// GmZOE6xqQ2WTfZ5ugZMyLg\n\nconst lUUIDAgain = toCanonicalUUID(lCompactUUID);\nconsole.log(\"Compacted UUID back to Canonical UUID again:\", lUUIDAgain);\n// 1a664e13-ac6a-4365-937d-9e6e8193322e\n\n// If you're not sure where either the source of the UUID or the short form can be\n// trusted to always have valid UUID's, or shortened ones, you can use the `isValidUUID`\n// and `isValidBase64URL` functions to check if the input is valid like so:\n\nlet compactedMaybe: string = \"\";\nif (isValidUUID(lUUID)) {\n  compactedMaybe = toCompactUUID(lUUID);\n  console.log(\"Valid UUID; compacted:\", compactedMaybe);\n} else {\n  throw new Error(\"Not a valid compact UUID\");\n}\n\nlet backToUUIDMaybe: string = \"\";\nif (isValidCompactUUID(lCompactUUID)) {\n  backToUUIDMaybe = toCanonicalUUID(lCompactUUID);\n  console.log(\"Valid compact UUID; back to canonical:\", backToUUIDMaybe);\n} else {\n  throw new Error(\"Not a valid compact UUID (base64url string)\");\n}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsverweij%2Fuuid-compact","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsverweij%2Fuuid-compact","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsverweij%2Fuuid-compact/lists"}