@appliedblockchain/helpers
Advanced tools
Comparing version 2.0.2 to 2.0.3
{ | ||
"name": "@appliedblockchain/helpers", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "No dependency, single file helpers.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
// @flow | ||
const { randomBytes } = require('crypto') | ||
const { mask, variantRfc4122 } = require('./uuid') | ||
const uuidStringOfBuffer = require('./uuid-string-of-buffer') | ||
const h = [] | ||
for (let i = 0; i < 0xff; ++i) { | ||
h[i] = i.toString(16).padStart(2, '0') | ||
function uuidV4() /*: string */ { | ||
return uuidStringOfBuffer(mask(randomBytes(16), 4, variantRfc4122)) | ||
} | ||
function uuidV4() { | ||
const x = randomBytes(16) | ||
x[6] = (x[6] & 0x0f) | 0x40 | ||
x[8] = (x[8] & 0x3f) | 0x80 | ||
return [ | ||
h[x[0]], h[x[1]], h[x[2]], h[x[3]], '-', | ||
h[x[4]], h[x[5]], '-', | ||
h[x[6]], h[x[7]], '-', | ||
h[x[8]], h[x[9]], '-', | ||
h[x[10]], h[x[11]], h[x[12]], h[x[13]], h[x[14]], h[x[15]] | ||
].join('') | ||
} | ||
module.exports = uuidV4 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73103
60
2262