npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cbortech/uuid

v0.1.2

Published

A modern, type-safe TypeScript library for parsing and generating UUIDs (v1-v8, v7-first; RFC 9562).

Readme

@cbortech/uuid

TypeScript library for generating, parsing, and inspecting UUIDs.

This package supports UUID versions 1 through 8 as defined by RFC 9562, with convenient helpers for UUID v4 and monotonic UUID v7.

Install

npm install @cbortech/uuid

Import

import { UUID } from '@cbortech/uuid';

Default import is also supported:

import UUID from '@cbortech/uuid';

CommonJS is supported too:

const { UUID } = require('@cbortech/uuid');

Quick Examples

Generate UUID v7

import { UUID } from '@cbortech/uuid';

const uuid = UUID.random({ ver: 7 });

console.log(uuid.toString());
// 019ca305-7aa2-7d6b-8b95-fbcbf17e1d66

console.log(uuid.getVersion());
// 7

console.log(new Date(uuid.getTime()).toISOString());
// 2026-02-28T06:52:51.234Z

UUID.random({ ver: 7 }) generates monotonically increasing UUIDs when called multiple times within the same millisecond in the same JavaScript runtime.

Generate UUID v4

import { UUID } from '@cbortech/uuid';

const uuid = UUID.random();

console.log(uuid.toString());
// 550e8400-e29b-41d4-a716-446655440000

Parse a UUID

import { UUID } from '@cbortech/uuid';

const uuid = new UUID('017f22e2-79b0-7cc3-98c4-dc0c0c07398f');
const parsed = uuid.parse();

console.log(parsed);
// {
//   ver: 7,
//   unix_ts_ms: 1645557742000,
//   rand_a: 3267,
//   var: 'RFC4122',
//   rand_b: 0x18c4dc0c0c07398fn
// }

Convert to and from bytes

import { UUID } from '@cbortech/uuid';

const uuid = new UUID('550e8400-e29b-41d4-a716-446655440000');
const bytes = uuid.toBytes();
const copy = new UUID(bytes);

console.log(copy.equals(uuid));
// true

Create special UUID values

import { UUID } from '@cbortech/uuid';

console.log(UUID.nil().toString());
// 00000000-0000-0000-0000-000000000000

console.log(UUID.max().toString());
// ffffffff-ffff-ffff-ffff-ffffffffffff

Constructor Inputs

new UUID(input) accepts:

  • UUID strings, with or without braces or hyphens
  • Uint8Array, DataView, ArrayBuffer, and other array buffer views
  • another UUID instance
  • UUID option objects for versions 1 through 8
  • undefined for a random UUID v4
  • null for the Nil UUID

Examples:

new UUID('017f22e2-79b0-7cc3-98c4-dc0c0c07398f');
new UUID('{295714e9-5955-40b4-b69b-9758989a6c06}');
new UUID(new Uint8Array(16));
new UUID({ ver: 7 });
new UUID(null);

The object returned by uuid.parse() can be passed back to the constructor for round-trip operations:

const uuid = new UUID('017f22e2-79b0-7cc3-98c4-dc0c0c07398f');
const copy = new UUID(uuid.parse());

console.log(copy.equals(uuid));
// true

API

uuid.getVersion(): number
uuid.getVariant(): 'NCS' | 'RFC4122' | 'Microsoft' | 'Reserved'
uuid.getTime(): number
uuid.toString(): string
uuid.toBytes(): Uint8Array
uuid.toJSON(): string
uuid.parse(): ParsedUUID
uuid.equals(other: UUID): boolean
uuid.isNil(): boolean
uuid.isMax(): boolean

UUID.nil(): UUID
UUID.max(): UUID
UUID.random(options?: { ver?: 4 | 7 }): UUID

getTime() is available for time-based UUIDs: v1, v2, v6, and v7. For UUID v2, the recovered timestamp is coarse because v2 replaces part of the timestamp with the local identifier.

For detailed field access such as clock_seq, node, rand_a, or rand_b, use parse(). It returns a version-specific object.

CLI

A command-line interface built on this package is available as @cbortech/uuid-cli.

Runtime

  • Node.js 20 or newer
  • Modern browsers with Web Crypto

This library uses crypto.getRandomValues() when available. If Web Crypto is unavailable, it falls back to Math.random(), which is not suitable for security-sensitive UUID generation.

Public API

The documented public export is:

  • UUID

The package also exports the related TypeScript types used by the UUID API.

Specifications

RFC 4122 is the older UUID specification and is superseded by RFC 9562.

License

Apache-2.0