@arms/rum-core
Advanced tools
Comparing version 0.0.25-beta.11 to 0.0.25-beta.13
@@ -18,5 +18,6 @@ /** | ||
* @param len {number} | ||
* @param radix {number} | ||
* @return {String} | ||
*/ | ||
export declare function generateSpanId(len?: number): string; | ||
export declare function generateSpanId(len?: number, radix?: number): string; | ||
/** | ||
@@ -23,0 +24,0 @@ * @description: 随机生成 eventId |
@@ -37,4 +37,14 @@ "use strict"; | ||
guid = crypto.randomUUID(); | ||
} else if (crypto && crypto.getRandomValues) { | ||
var buf = new Uint8Array(16); | ||
crypto.getRandomValues(buf); | ||
buf[6] = buf[6] & 0x0f | 0x40; // version 4 UUID | ||
buf[8] = buf[8] & 0x3f | 0x80; // variant 10xxxxxx | ||
guid = buf.reduce(function (str, _byte) { | ||
return str + _byte.toString(16).padStart(2, '0'); | ||
}, '').replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, '\$1-\$2-\$3-\$4-\$5'); | ||
} | ||
} catch (e) {} | ||
} catch (e) { | ||
// | ||
} | ||
if (!guid) { | ||
@@ -69,17 +79,17 @@ guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { | ||
* @param len {number} | ||
* @param radix {number} | ||
* @return {String} | ||
*/ | ||
function generateSpanId(len) { | ||
function generateSpanId(len, radix) { | ||
if (len === void 0) { | ||
len = 16; | ||
} | ||
var list = Array(len); | ||
if (radix === void 0) { | ||
radix = 16; | ||
} | ||
var result = ''; | ||
for (var i = 0; i < len; i++) { | ||
list[i] = Math.floor(Math.random() * 16) + 48; | ||
// valid hex characters in the range 48-57 and 97-102 | ||
if (list[i] >= 58) { | ||
list[i] += 39; | ||
} | ||
result += Math.floor(Math.random() * radix).toString(radix); | ||
} | ||
return String.fromCharCode.apply(null, list); | ||
return result; | ||
} | ||
@@ -86,0 +96,0 @@ |
{ | ||
"name": "@arms/rum-core", | ||
"version": "0.0.25-beta.11", | ||
"version": "0.0.25-beta.13", | ||
"description": "arms rum javascript sdk core", | ||
@@ -5,0 +5,0 @@ "author": "guangli.fj <guangli.fj@alibaba-inc.com>", |
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
46006
1400