Universally unique identifier in short web friendly (non UUID) format


Generated id's are composed out of current microseconds stamp, and random string.

Generate id based on current time and random string:

var generateId = require('time-uuid');
console.log(generateId()); // 7e7b249ksny 
console.log(generateId()); // 7e7b249wyjy 
console.log(generateId()); // 7e7b24ahlgy 

Get unique time (in microseconds):

It doesn't guarantee accurate time representation, in first place it's about provision of unique microtime value and optionally it relies on some microtime provider which may not be available in current environement

var getTime = require('time-uuid/time');
console.log(getTime()); // 1356631360599486 
console.log(getTime()); // 1356631360599698 
console.log(getTime()); // 1356631360603625 

Get unique id out of given microtime value

var getIdByTime = require('time-uuid/get-by-time');
console.log(getIdByTime(getTime())); // 7e7b24alj5y 
console.log(getIdByTime(getTime())); // 7e7b24aljyy 
console.log(getIdByTime(getTime())); // 7e7b24alkhy 
$ npm install time-uuid

To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: Browserify, Webmake or Webpack


$ npm test