All Projects → sw-yx → uuid-list

sw-yx / uuid-list

Licence: other
list of unique id implementations, design considerations, and resources.

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
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].