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

uuid-v8

v0.0.6

Published

An experimental implementation of the proposed UUID Version 8

Downloads

28

Readme

uuid-v8

An experimental implementation of the proposed UUID Version 8

Installation

npm install uuid-v8 --save

Default

import { uuidv8 } from "uuid-v8";

const result = uuidv8(); // e.g., "07e70c15-0f38-8bfc-ba65-f0ec85dc2812"
(or)
const { uuidv8 } = require("uuid-v8")

const result = uuidv8(); // e.g., "07e70c15-0f38-8bfc-ba65-f0ec85dc2812"

with custom time

import { UUID } from "uuid-v8";

//current Time
const uuid1 = UUID.generate(); // e.g., "07e70c16-0631-870e-0316-e51b1fab5ebb"

//Generate for a given time
var t = new Date()
const uuid2 = UUID.generate({time:t}); 

Get time associated with the UUID

import { UUID } from "uuid-v8";

//Gets the time associated with the UUID
const date = UUID.getTime('07e70c16-0631-870e-0316-e51b1fab5ebb'); 

Parse the UUID to Bytes

import { UUID } from "uuid-v8";

//Gets the time associated with the UUID
const bytes = UUID.parse('07e70c16-0631-870e-0316-e51b1fab5ebb'); 

const bytesInHex = UUID.parseToHex('07e70c16-0631-870e-0316-e51b1fab5ebb'); 

Command-line interface:

$ npx uuid-v8
07e70c16-0637-8003-0139-e65bfe87ae09
$
$ npx uuid-v8 -n 4
07e70c16-0637-8e13-0085-98ded92d312c
07e70c16-0637-8713-0087-558d00e6ffa1
07e70c16-0637-8e13-0087-8deb1113ab9e
07e70c16-0637-8313-0088-bdc6ff36d2fc
07e70c16-0637-8713-0088-02fbd0573c85

See draft-ietf-uuidrev-rfc4122bis-11.

Field and bit layout

UUID version 8 provides an RFC-compatible format for experimental or vendor-specific use cases. The only requirement is that the variant and version bits MUST be set as defined in Section 4.1 and Section 4.2. UUIDv8's uniqueness will be implementation-specific and MUST NOT be assumed.The only explicitly defined bits are those of the version and variant fields, leaving 122 bits for implementation specific UUIDs. To be clear: UUIDv8 is not a replacement for UUIDv4 Section 5.4 where all 122 extra bits are filled with random data.Some example situations in which UUIDv8 usage could occur: An implementation would like to embed extra information within the UUID other than what is defined in this document. An implementation has other application/language restrictions which inhibit the use of one of the current UUIDs.

 0                   10                  20                  30
 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 A B C D E F
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        year-month-day                         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          hour:minute          |  ver  | rand  |    seconds    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|var| milliseconds  |                   rand                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             rand                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

License

The MIT License (MIT)

External Links