Unique generates IDs, that is all. The IDs that are generated have the following properties.
- Portable - Unique generates String IDs so they can be used anywhere.
- Compact - Unique Base64 encodes IDs to minimize wasted space.
- Timely - Unique includes a timestamp to the millisecond in its IDs.
- Orderly - Unique IDs are lexicographically ordered by time.
- Random - Unique includes 122 random bits in its IDs.
base64(bin(hex(now()) + uuidV4()))
now()returns an integer representing milliseconds since epoch
uuidV4()returns a 32 character hex string (no dashes)
unique([ts]) - Generates a new id.
ts: Date (Optional)
- Description: A date representing the timestamp you want encoded into your ID.
- Default: Now.
unique.getTimestamp(id) - Returns the timestamp encoded in the given id.
- Description: An id to extract the timestamp from.