UNPKG

1.03 kBJavaScriptView Raw
1!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).uuidv4=e()}(this,(function(){"use strict";var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),e=new Uint8Array(16);function o(){if(!t)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(e)}for(var n=[],r=0;r<256;++r)n.push((r+256).toString(16).substr(1));return function(t,e,r){var u=(t=t||{}).random||(t.rng||o)();if(u[6]=15&u[6]|64,u[8]=63&u[8]|128,e){r=r||0;for(var d=0;d<16;++d)e[r+d]=u[d];return e}return function(t,e){var o=e||0;return(n[t[o+0]]+n[t[o+1]]+n[t[o+2]]+n[t[o+3]]+"-"+n[t[o+4]]+n[t[o+5]]+"-"+n[t[o+6]]+n[t[o+7]]+"-"+n[t[o+8]]+n[t[o+9]]+"-"+n[t[o+10]]+n[t[o+11]]+n[t[o+12]]+n[t[o+13]]+n[t[o+14]]+n[t[o+15]]).toLowerCase()}(u)}}));
\No newline at end of file