@arcblock/forge-util
Advanced tools
Comparing version 0.29.0 to 0.29.3
@@ -12,2 +12,15 @@ // Generate by [js2dts@0.3.3](https://github.com/whxaxes/js2dts#readme) | ||
declare function isUint8Array(value: any): boolean; | ||
/** | ||
* Generate a random UUID | ||
* | ||
* @returns {string} generated uuid | ||
*/ | ||
declare function UUID(): string; | ||
/** | ||
* Check if a string is valid UUID | ||
* | ||
* @param {string} str | ||
* @returns {boolean} | ||
*/ | ||
declare function isUUID(str: string): boolean; | ||
declare const _Lib: _Lib.T100; | ||
@@ -36,4 +49,6 @@ declare namespace _Lib { | ||
toBN: (number: any) => any; | ||
UUID: typeof UUID; | ||
isUUID: typeof isUUID; | ||
} | ||
} | ||
export = _Lib; |
@@ -483,2 +483,25 @@ /* eslint-disable no-bitwise */ | ||
/** | ||
* Generate a random UUID | ||
* | ||
* @returns {string} generated uuid | ||
*/ | ||
function UUID() { | ||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => { | ||
const r = (Math.random() * 16) | 0; | ||
const v = c === 'x' ? r : (r & 0x3) | 0x8; | ||
return v.toString(16); | ||
}); | ||
} | ||
/** | ||
* Check if a string is valid UUID | ||
* | ||
* @param {string} str | ||
* @returns {boolean} | ||
*/ | ||
function isUUID(str) { | ||
return /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/.test(str); | ||
} | ||
module.exports = { | ||
@@ -505,2 +528,4 @@ isBN, | ||
toBN, | ||
UUID, | ||
isUUID, | ||
}; |
{ | ||
"name": "@arcblock/forge-util", | ||
"version": "0.29.0", | ||
"version": "0.29.3", | ||
"description": "utils shared across mutlipe forge js libs, works in both node.js and browser", | ||
@@ -54,3 +54,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "6e922db0d834db071d8208d56cbf46175192e301" | ||
"gitHead": "7df2a2535997bb7606e9ada527d103f47fa698b8" | ||
} |
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
16192
516