0.0.1 • Published 9 years ago
time-uid v0.0.1
time uid
Yet another unique id module, for use in distributed systems. Features and Requirements
- all uids from a given user must be in lexicographical order
- all uids from all concurrent users must be unique with a certain probability
- ability to change the uid length for nested groups
This module is for cases where a lighter UID can be used in sub-groups (project files, thread messages)
Example id1/id2: /cIWr5hA4peMq6/h0ApXe3hZ
For comparison, below are example of available alternatives:
npm timer-uid, 20char, firebase, style/-IWr5h0A4pe3h_mjpZq6/_IWr5h0A4pe3hMmjpZq6
npm cuid/c-h72gsb32-0000-udoc-l363eofy/c-h72gsb32-0000-udoc-l363eofy
- RFC-4122 style
/f81d4fae-7dec-11d0-a765-00a0c91e6bf6/f81d4fae-7dec-11d0-a765-00a0c91e6bf6
API
var TUID = require('tuid')
var tuid = TUID({users: 25, odds: 1e12, startDate: '2010-01-01'}),
uid0 = tuid()Options and Defaults
chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', character setstartDate = '2016-01-01', the beginning of timetMin = 17, minimum time interval in ms (~= 1000/62)tMax = 29 * SECONDS_PER_YEAR * 1000, maximum time in ms (29 years ~= 62^5)length = 10// default set at 4 char randomusers = 20, minimum concurrent users making simultaneous editsodds = 1e12mininimum odds of a duplicate uid per second (1 in ...)
others modules on npm
- (+)
cuid, c-h72gsb32-0000-udoc-l363eofy, 29char - (+)
puid, 4 sections and has 24 chars - (+)
timer-uid, 20char, 8time + 12rnd, same as firebase component-uid, random onlygen-uidgenuid, random onlyj-uidlite-id, random onlymicro-uidmicro-uid, random base 62 uidnid, random onlypure-uuid, RFC-4122random-bytes, random onlyrandom-id, random onlyrndm, random onlyscuid, ciuwr5ekh00044pe13ruhsmjpq6, 27char, randomshort-uid, generates IDs of increasing lengthshort-uuid, ??simple-random-id, random onlysimple-uid, node-oly, 24-bytes of chaos, Base64smart-id, random onlyuid-safe, cryptouid-utiluid, variable length, random onlyuid2uniqid, Unique Hexatridecimal ID generator (base16)unique-id-generator, Date.now, prefix, numbers only (base10)unique-iduniqueuuid-pure, ???uuid-token-generator, ???
0.0.1
9 years ago