typescript-guid is a lightweight utility library for generating, parsing, and manipulating Globally Unique Identifiers (GUIDs), also commonly known as UUIDs, within TypeScript and JavaScript environments. The current stable version is 1.0.3. The library offers a comprehensive set of static methods for creating new GUIDs, including empty GUIDs, parsing GUID strings into `Guid` objects, and validating arbitrary values against the GUID format. `Guid` instances support comparisons (case-insensitive since v1.0.1), emptiness checks, and serialization to string or JSON formats. It is a direct evolution of the original `guid-typescript` project, distinguished by its strong emphasis on type safety and a TypeScript-first API design, ensuring seamless integration into modern TypeScript codebases. The project's release cadence is primarily driven by bug fixes and dependency updates, indicating a stable and mature codebase.
npm install typescript-guidVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates creating new GUIDs, parsing existing ones, comparing `Guid` instances, and validating GUID strings. It showcases the primary API methods for common UUID operations.
Review any code that compares `Guid` objects using the `equals` method. If case-sensitivity was a requirement, you may need to implement custom string comparison after converting GUIDs to string format.
Always use `import { Guid } from 'typescript-guid';` for importing the library. Ensure your project is configured to handle ES modules (e.g., via `"type": "module"` in `package.json` for Node.js, or a bundler like Webpack/Rollup for browser applications).Use static factory methods like `Guid.create()` to generate a new GUID, or `Guid.parse(guidString)` to create one from a string.
Verify that your Node.js project or build setup correctly handles ES Modules. For Node.js, ensure `"type": "module"` is set in your `package.json` or use a transpiler like Babel/TypeScript to convert ESM to CommonJS if strictly necessary for an older runtime.
No dependency data recorded yet.