Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.
/ uuid-list Public archive

list of unique id implementations, design considerations, and resources.

Notifications You must be signed in to change notification settings

swyxio/uuid-list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 

Repository files navigation

this list is now archived - look inside https://github.com/sw-yx/brain if you would like an updated list! thank you.

uuid-list

list of unique id implementations, design considerations, and resources. may also overlap somewhat with the topic of hashing

Desirable Properties

  • extremely low chance of collision
  • sorting
    • chronologically sortable
    • lexicographically/alphabetically sortable? (k-sortable?)
  • speed
  • string qualities
    • case insensitive
    • URL safe
    • 64 bits (instead of 128bits) or otherwise fixed length (bc of storage concerns)
  • secure/good entropy
    • non-secure = Math.random + Date.now
    • cryptographically secure = CSPRNG - use crypto module in node.js
    • ?
  • inputs:
    • timestamp
    • string?
  • no dependencies
  • no need for coordination (among different clients generating uuid's)

Concepts

Impls

grab n go: https://www.uuidgenerator.net/

super simple dumb unique id

function id () {
  return Math.random().toString(36).substring(2) + Date.now().toString(36);
}

better uuid?

https://www.w3resource.com/javascript-exercises/javascript-math-exercise-23.php
export function uuid() {
  var dt = new Date().getTime()
  var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(
    c
  ) {
    var r = (dt + Math.random() * 16) % 16 | 0
    dt = Math.floor(dt / 16)
    // eslint-disable-next-line
    return (c == 'x' ? r : (r & 0x3) | 0x8).toString(16)
  })
  return uuid
}

About

list of unique id implementations, design considerations, and resources.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published