Const uuid4
uuid4: uuid4 = (() => {// Create a 16 byte array to hold the random values.const bytes = new Uint8Array(16);// Create a look up table from bytes to hex strings.const lut = new Array<string>(256);// Pad the single character hex digits with a leading zero.for (let i = 0; i < 16; ++i) {lut[i] = '0' + i.toString(16);}// Populate the rest of the hex digits.for (let i = 16; i < 256; ++i) {lut[i] = i.toString(16);}// Return a function which generates the UUID.return function uuid4(): string {// Get a new batch of random values.Random.getRandomValues(bytes);// Set the UUID version number to 4.bytes[6] = 0x40 | (bytes[6] & 0x0F);// Set the clock sequence bit to the RFC spec.bytes[8] = 0x80 | (bytes[8] & 0x3F);// Assemble the UUID string.return (lut[bytes[0]] +lut[bytes[1]] +lut[bytes[2]] +lut[bytes[3]] +'-' +lut[bytes[4]] +lut[bytes[5]] +'-' +lut[bytes[6]] +lut[bytes[7]] +'-' +lut[bytes[8]] +lut[bytes[9]] +'-' +lut[bytes[10]] +lut[bytes[11]] +lut[bytes[12]] +lut[bytes[13]] +lut[bytes[14]] +lut[bytes[15]]);}})()
The namespace for UUID related functionality.