{"id":22793078,"url":"https://github.com/kripod/uuidv7","last_synced_at":"2025-04-13T08:40:34.388Z","repository":{"id":37623990,"uuid":"408794054","full_name":"kripod/uuidv7","owner":"kripod","description":"UUIDv7 generator with millisecond precision","archived":false,"fork":false,"pushed_at":"2022-08-25T05:51:00.000Z","size":569,"stargazers_count":109,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-27T00:13:29.497Z","etag":null,"topics":["collision-resistance","id-generator","k-sortable"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/kripod.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"kripod"}},"created_at":"2021-09-21T11:31:50.000Z","updated_at":"2024-11-18T09:46:12.000Z","dependencies_parsed_at":"2022-08-31T08:12:04.188Z","dependency_job_id":null,"html_url":"https://github.com/kripod/uuidv7","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kripod%2Fuuidv7","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kripod%2Fuuidv7/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kripod%2Fuuidv7/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kripod%2Fuuidv7/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kripod","download_url":"https://codeload.github.com/kripod/uuidv7/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248685744,"owners_count":21145340,"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":["collision-resistance","id-generator","k-sortable"],"created_at":"2024-12-12T03:17:56.220Z","updated_at":"2025-04-13T08:40:34.338Z","avatar_url":"https://github.com/kripod.png","language":"TypeScript","funding_links":["https://github.com/sponsors/kripod"],"categories":[],"sub_categories":[],"readme":"# UUIDv7\n\nUUIDv7 generator based on the [RFC4122 update proposal (draft-04)](https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-04.html)\n\n[![npm (scoped)](https://img.shields.io/npm/v/@kripod/uuidv7)](https://www.npmjs.com/package/@kripod/uuidv7)\n[![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/@kripod/uuidv7)](https://bundlephobia.com/package/@kripod/uuidv7)\n[![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/kripod/uuidv7/Node.js%20CI/main)](https://github.com/kripod/uuidv7/actions/workflows/node-ci.yaml)\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](./CODE_OF_CONDUCT.md)\n\n## Usage\n\n```js\nimport { uuidv7 } from \"@kripod/uuidv7\";\n\nlet id = uuidv7();\nconsole.log(id); // Example: 00ccebbc-13e0-7000-8b18-6150ad2d0c05\n```\n\n## Key features\n\n- K-sortable with 1ms precision _(Safari disallows sub-ms timing [to defend against Spectre](https://webkit.org/blog/8048/what-spectre-and-meltdown-mean-for-webkit/))_\n- Time-ordered when sorted lexicographically\n- Collision-resistant with distributed systems in mind\n- Works until the year 10889, after which timestamps would overflow\n\n## Compatibility\n\n| Chrome | Safari | Firefox |         IE          | Node.js | Deno |\n| :----: | :----: | :-----: | :-----------------: | :-----: | :--: |\n|  ≥57   |  ≥10   |   ≥48   | No _(polyfillable)_ |   ≥8    |  ≥1  |\n\n### Supporting additional runtimes\n\n- [`String.prototype.padStart`](https://caniuse.com/pad-start-end)\n\n  - Included in popular frameworks:\n\n    - Next.js\n    - Nuxt\n    - Gatsby\n\n  - Polyfillable using [core-js](https://github.com/zloirock/core-js), preferably [within `\u003cscript nomodule\u003e`](https://3perf.com/blog/polyfills/#modulenomodule):\n\n    ```js\n    import \"core-js/features/string/pad-start\";\n    ```\n\n- [`crypto.getRandomValues()`](https://caniuse.com/getrandomvalues)\n\n  - IE 11:\n\n    ```js\n    if (typeof window !== \"undefined\" \u0026\u0026 !window.crypto \u0026\u0026 window.msCrypto) {\n      window.crypto = window.msCrypto;\n    }\n    ```\n\n## Binary structure\n\n- `unix_ts_ms`: Milliseconds elapsed since the Unix epoch – 48 bits\n- `ver`: UUID version (`7`) – 4 bits\n- `rand_a`: Monotonic sequence counter for more precise sorting – 12 bits\n- `var`: UUID variant (`0b10`) – 2 bits\n- `rand_b`: Cryptographically strong random data – 62 bits\n\n\u003cdiv aria-hidden=\"true\"\u003e\n\n```\n 0                   1                   2                   3\n 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1\n┌─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┐\n│                          unix_ts_ms                           │\n├─┴─┴─┴─┼─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┼─┴─┴─┴─┼─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤\n│          unix_ts_ms           │  ver  │        rand_a         │\n├─┴─┼─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤\n│var│                        rand_b                             │\n├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤\n│                            rand_b                             │\n└─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘\n```\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkripod%2Fuuidv7","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkripod%2Fuuidv7","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkripod%2Fuuidv7/lists"}