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-random

v1.3.2

Published

Fastest UUIDv4 with good RNG

Downloads

666,690

Readme

uuid-random

MIT Licence Stable

Generate RFC-4122 compliant random UUIDs (version 4) with better statistical dispersion than Math.random().

Install

npm i uuid-random

Or download the latest release.

Features

Compatability

Compatible with almost all versions of:

  • Node
  • Babel
  • TypeScript
  • Web browsers

Performance

The included benchmark.js as well as independent benchmarks rank this library as the fastest pure JS UUID v4 generator available with cryptographically secure PRNG— almost 20x faster than the most popular library (using latest NodeJS).

| npm package | performance | |-----------------|-----------------| | portable-uuid | 354k ops/sec | | uuid | 474k ops/sec | | id128 | 6.0M ops/sec | | uuid-random (this) | 9.7M ops/sec |

Results above generated on a 4.20GHz Intel i7-7700K with Node v12.18.0

Why use UUID?

Universally Unique IDentifiers transcend many constraints of traditional incremental integer IDs, especially in distributed systems. In UUID version 4, we essentially generate a random 128-bit value.

We do trade guaranteed uniqueness for extremely probable uniqueness (you would need to do-loop uuid() at max speed for 73,067 years for a 50% chance of one collision). But for that slight cost, we may now generate valid, unique, persistent IDs on any node of a distributed system (e.g. intermittently offline or high-latency clients).

Note, if you plan to use UUIDs for a new project, depending on your requirements, you may consider a more recent standard that addresses some of the shortcomings of UUID, such as flake-id, nanoid, cuid, or ulid.

Example Usage

Babel

import uuid from 'uuid-random';
uuid(); // 'f32dc9ae-7ca8-44ca-8f25-f258f7331c55'

Node

var uuid = require('uuid-random');
uuid(); // '0b99b82f-62cf-4275-88b3-de039020f14e'

Browser

<script src="uuid-random.min.js"></script>
<script>
  uuid(); // 'b96ab5e6-f1e8-4653-ab08-4dd82ea65778'
</script>

Validate a UUID v4 String

uuid.test('0b99b82f-62cf-4275-88b3-de039020f14e'); // true

Generate Binary UUIDs

uuid.bin(); // <Buffer 41 db 10 54 b3 61 48 50 87 f1 2f 7b 08 a5 0f 06>

Contributing

Feel free to open an issue or submit a pull request.

License

MIT.