{"id":14529705,"url":"https://github.com/jetify-com/typeid-js","last_synced_at":"2025-05-14T18:02:24.856Z","repository":{"id":177411625,"uuid":"660260367","full_name":"jetify-com/typeid-js","owner":"jetify-com","description":"TypeScript implementation of TypeIDs: type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs","archived":false,"fork":false,"pushed_at":"2025-03-07T23:17:26.000Z","size":100,"stargazers_count":345,"open_issues_count":1,"forks_count":8,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-14T01:49:28.715Z","etag":null,"topics":["guid","js","ts","typeid","typescript","uuid","uuidv7"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jetify-com.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-29T15:44:41.000Z","updated_at":"2025-04-11T10:22:04.000Z","dependencies_parsed_at":"2023-12-01T23:22:07.315Z","dependency_job_id":"fcdc9c9e-52a7-4c53-9aa3-97b39ee4e415","html_url":"https://github.com/jetify-com/typeid-js","commit_stats":null,"previous_names":["jetpack-io/typeid-ts","jetify-com/typeid-js","jetpack-io/typeid-js"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jetify-com%2Ftypeid-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jetify-com%2Ftypeid-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jetify-com%2Ftypeid-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jetify-com%2Ftypeid-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jetify-com","download_url":"https://codeload.github.com/jetify-com/typeid-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254198453,"owners_count":22030964,"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":["guid","js","ts","typeid","typescript","uuid","uuidv7"],"created_at":"2024-09-05T00:01:01.828Z","updated_at":"2025-05-14T18:02:24.512Z","avatar_url":"https://github.com/jetify-com.png","language":"TypeScript","readme":"# Official TypeID-JS Package\n![License: Apache 2.0](https://img.shields.io/github/license/jetify-com/typeid) [![Built with Devbox](https://www.jetify.com/img/devbox/shield_galaxy.svg)](https://www.jetify.com/devbox)\n\n### JavaScript implementation of [TypeIDs](https://github.com/jetify-com/typeid) using TypeScript.\n\nTypeIDs are a modern, **type-safe**, globally unique identifier based on the upcoming\nUUIDv7 standard. They provide a ton of nice properties that make them a great choice\nas the primary identifiers for your data in a database, APIs, and distributed systems.\nRead more about TypeIDs in their [spec](https://github.com/jetify-com/typeid).\n\nThis is the official JavaScript / TypeScript implementation of TypeID by the\n[jetify](https://www.jetify.com) team. It provides an [npm package](https://www.npmjs.com/package/typeid-js) that can be used by\nany JavaScript or TypeScript project.\n\n#### **_ If you wish to use a string-based representation of typeid (instead of class-based), please follow the instructions [here](src/unboxed/README.md). _**\n\n# Installation\n\nUsing npm:\n\n```bash\nnpm install typeid-js\n```\n\nUsing yarn:\n\n```bash\nyarn add typeid-js\n```\n\nUsing pnpm:\n\n```bash\npnpm add typeid-js\n```\n\nNote: this package requires Typescript \u003e 5.0.0\n\n# Usage\n\nTo create a random TypeID of a given type, use the `typeid()` function:\n\n```typescript\nimport { typeid } from 'typeid-js';\nconst tid = typeid('prefix');\n```\n\nThe prefix is optional, so if you need to create an id without a type prefix, you\ncan do that too:\n\n```typescript\nimport { typeid } from 'typeid-js';\nconst tid = typeid();\n```\n\nThe return type of `typeid(\"prefix\")` is `TypeID\u003c\"prefix\"\u003e`, which lets you use\nTypeScript's type checking to ensure you are passing the correct type prefix to\nfunctions that expect it.\n\nFor example, you can create a function that only accepts TypeIDs of type `user`:\n\n```typescript\nimport { typeid, TypeID } from 'typeid-js';\n\nfunction doSomethingWithUserID(id: TypeID\u003c'user'\u003e) {\n    // ...\n}\n```\n\nIn addition to the `typeid()` function, the `TypeID` class has additional methods\nto encode/decode from other formats.\n\nFor example, to parse an existing typeid from a string:\n\n```typescript\nimport { TypeID } from 'typeid-js';\n\n// The prefix is optional, but it enforces the prefix and returns a\n// TypeID\u003c\"prefix\"\u003e instead of TypeID\u003cstring\u003e\nconst tid = TypeID.fromString('prefix_00041061050r3gg28a1c60t3gf', 'prefix');\n```\n\nTo encode an existing UUID as a TypeID:\n\n```typescript\nimport { TypeID } from 'typeid-js';\n\n// In this case TypeID\u003c\"prefix\"\u003e is inferred from the first argument\nconst tid = TypeID.fromUUID('prefix', '00000000-0000-0000-0000-000000000000');\n```\n\nThe full list of methods includes:\n\n-   `getType()`: Returns the type of the type prefix\n-   `getSuffix()`: Returns uuid suffix in its base32 representation\n-   `toString()`: Encodes the object as a string, using the canonical format\n-   `toUUID()`: Decodes the TypeID into a UUID string in hex format. The type prefix is ignored\n-   `toUUIDBytes()`: Decodes the TypeID into a UUID byte array. The type prefix is ignored\n-   `fromString(str, prefix?)`: Parses a TypeID from a string, optionally checking the prefix\n-   `fromUUID(prefix, uuid)`: Creates a TypeID from a prefix and a UUID in hex format\n-   `fromUUIDBytes(prefix, bytes)`: Creates a TypeID from a prefix and a UUID in byte array format\n","funding_links":[],"categories":["**1. Libraries**","TypeScript","Libraries"],"sub_categories":["Others","Services"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjetify-com%2Ftypeid-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjetify-com%2Ftypeid-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjetify-com%2Ftypeid-js/lists"}