1.0.0 • Published 6 years ago

vuid v1.0.0

Weekly downloads
50
License
MIT
Repository
-
Last release
6 years ago

vuid

very unique identifiers

This module exports a tiny (144B) function that generates UUIDv4 compliant identifiers in the browser. It takes advantages of and relies on the browsers built in crypto API; namely the getRandomValues function. This offers a better level of randomness than Math.random but means will not work in a node environment.

For all practical purposes the generated identifiers can be considered universally unique. The chance of two ever colliding is less than 1 in 5316911983139663491615228241121378304. Which is a pretty cool guarantee.

For a history on the conception and evolution of this solution see:

Import

You can install the package from npm and load it from node_modules or import it directly from unpkg in a script tag with type="module".

import vuid from 'vuid'
import vuid from 'https://unpkg.com/vuid'

Usage

Call the imported function.

vuid() // 6dfc8a40-2d34-45b5-b3ab-aaf168e71aed