Skip to content

Instantly share code, notes, and snippets.

@simonkberg
Created May 27, 2019 13:08
Show Gist options
  • Save simonkberg/ae5fcdeac91fbc8d9e4d524862597ecb to your computer and use it in GitHub Desktop.
Save simonkberg/ae5fcdeac91fbc8d9e4d524862597ecb to your computer and use it in GitHub Desktop.
const srand32 = seed => {
const s = Math.sin(seed) * 10000;
return Math.floor((s - Math.floor(s)) * Math.pow(2, 32));
};
const suuid = seed =>
new Uint32Array(8)
.map((_, idx) => srand32(seed + idx))
.reduce((acc, val, idx) => acc + (idx < 2 || idx > 5 ? '' : '-') + val.toString(16).slice(-4), '');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment