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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@i-xi-dev/uuid

v3.2.2

Published

A JavaScript UUID generator, implements the version 3, 4, and 5 UUID defined in RFC 4122. And this generator implements version 7 draft proposed in RFC 4122 bis.

Downloads

70

Readme

@i-xi-dev/uuid

A JavaScript UUID generator, implements the version 3, 4, and 5 UUID defined in RFC 4122. And this generator implements version 7 draft proposed in RFC 4122 bis.

Requirement

Uuid.generateRandom and Uuid.generateUnixTimeBased methods

This requires Crypto.

| Chrome | Edge | Firefox | Safari | Deno | Node.js | | :---: | :---: | :---: | :---: | :---: | :---: | | ✅ | ✅ | ✅ | ✅ | ✅ | ✅15.0.0+ |

Uuid.fromName methods

Generating version 5 requires SubtleCrypto.

| Chrome | Edge | Firefox | Safari | Deno | Node.js | | :---: | :---: | :---: | :---: | :---: | :---: | | ✅ | ✅ | ✅ | ✅ | ✅ | ✅15.0.0+ |

SubtleCrypto is available in secure contexts, in browsers.

Installation

npm

$ npm i @i-xi-dev/[email protected]
import { Uuid } from "@i-xi-dev/uuid";

CDN

Example for UNPKG

import { Uuid } from "https://www.unpkg.com/@i-xi-dev/[email protected]/esm/mod.js";

Usage

Uuid class

Creates a version 4 UUID

const uuid = Uuid.generateRandom();
// uuid.toString();
//   → for example "5eb893ba-ec79-4f55-958d-66731227b662"

// Gets the variant, and the version
// uuid.variant;
//   → 2
// uuid.version;
//   → 4

// Gets the URN
const urn = uuid.toURN();
// urn.toString();
//   → for example "urn:uuid:5eb893ba-ec79-4f55-958d-66731227b662"

Creates an instance from string

const uuidB = Uuid.fromString("5eb893ba-ec79-4f55-958d-66731227b662");
const uuidC = Uuid.fromString("5eb893baec794f55958d66731227b662");
const uuidD = Uuid.fromString("5EB893BA-EC79-4F55-958D-66731227B662");
const uuidE = Uuid.fromString("5EB893BAEC794F55958D66731227B662");
const uuidF = Uuid.fromString("urn:uuid:5eb893ba-ec79-4f55-958d-66731227b662");

// uuidB.equals(uuidC);
//   → true
// uuidB.equals(uuidD);
//   → true
// uuidB.equals(uuidE);
//   → true
// uuidB.equals(uuidF);
//   → true

// uuidB.equals("5eb893ba-ec79-4f55-958d-66731227b662");
//   → true
// uuidB.equals("5eb893baec794f55958d66731227b662");
//   → true
// uuidB.equals("5EB893BA-EC79-4F55-958D-66731227B662");
//   → true
// uuidB.equals("5EB893BAEC794F55958D66731227B662");
//   → true
// uuidB.equals("urn:uuid:5eb893ba-ec79-4f55-958d-66731227b662");
//   → true
const uuidX = Uuid.fromString(crypto.randomUUID());

Creates a version 5 UUID

const namespace = Uuid.Namespace.URL; // 6ba7b811-9dad-11d1-80b4-00c04fd430c8
const uuid = await Uuid.fromName(namespace, "https://example.com/sample/123");
// uuid.toString();
//   → "7fdb2afb-a771-50eb-a0ae-7f02b933a569"

Creates a version 3 UUID

const namespace = Uuid.Namespace.URL; // 6ba7b811-9dad-11d1-80b4-00c04fd430c8
const uuid = await Uuid.fromName(namespace, "https://example.com/sample/123", 3);
// uuid.toString();
//   → "b131a200-1fa6-313e-b5d2-6b7a9b00570c"

Creates a version 7 UUID proposal

const uuid = Uuid.generateUnixTimeBased();
// uuid.toString();
//   → for example "018d8e7b-f31f-7000-98b7-4593649d25e1"
// new Date(uuid.unixTimeMilliseconds).toISOString();
//   → for example "2024-02-09T15:28:24.351Z"

The precision of the time is the greater of the following:

  • 1 millisecond
  • The precision of the time of performance.now() in execution environment

Note that some browsers have performance.now() precision greater than 1 millisecond, depending on settings and other factors.

Examples