Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Truly Unique Identifier
JavaScript
branch: master

Added jsFiddle demo link.

latest commit 425af7f8b4
Rishi Sharma authored
Failed to load latest commit information.
.gitignore Added .gitignore.
LICENSE Initial commit
README.md Added jsFiddle demo link.
tuid.js Replaced counter with Math.random; easier..

README.md

tuid

Truly Unique ID - A pure javascript unique id generator that guarantees uniqueness globally.

The generated id is a string with the first 32 characters being system generated, and the remaining digits representing the number of milliseconds since epoch (a handy timestamp!).

E.g.:
id -> ufqSJh_5h9sal7m_EC1R5EZIB59ZOwVP1401910420816
system_generated -> ufqSJh_5h9sal7m_EC1R5EZIB59ZOwVP
milliseconds since epoch -> 1401910420816

This is especially useful for client-side id generation. It's also not monotonically increasing!

Demo

See the demo on jsFiddle

Usage

Download and include tuid.js
<script type="text/javascript" src="tuid.js"></script>

Example

<script>
    // Pass the tuid() function a callback that will handle the generated id
    tuid(function(tuid){
      console.log(tuid); // => ufqSJh_5h9sal7m_EC1R5EZIB59ZOwVP1401910420816 
    });
</script>
Something went wrong with that request. Please try again.