Skip to content

Commit

Permalink
updates (#3162)
Browse files Browse the repository at this point in the history
  • Loading branch information
GLStephen authored and mkendall07 committed Oct 26, 2018
1 parent 50a7cff commit 5743e2b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,22 @@ exports.getUniqueIdentifierStr = _getUniqueIdentifierStr;
*/
exports.generateUUID = function generateUUID(placeholder) {
return placeholder
? (placeholder ^ Math.random() * 16 >> placeholder / 4).toString(16)
? (placeholder ^ _getRandomData() >> placeholder / 4).toString(16)
: ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, generateUUID);
};

/**
* Returns random data using the Crypto API if available and Math.random if not
* Method is from https://gist.github.com/jed/982883 like generateUUID, direct link https://gist.github.com/jed/982883#gistcomment-45104
*/
function _getRandomData() {
if (window && window.crypto && window.crypto.getRandomValues) {
return crypto.getRandomValues(new Uint8Array(1))[0] % 16;
} else {
return Math.random() * 16;
}
}

exports.getBidIdParameter = function (key, paramsObj) {
if (paramsObj && paramsObj[key]) {
return paramsObj[key];
Expand Down

0 comments on commit 5743e2b

Please sign in to comment.