@arcblock/forge-util
Advanced tools
Comparing version 0.12.2 to 0.12.3
@@ -15,2 +15,29 @@ // most functions are from: https://github.com/ethereum/web3.js/blob/1.0/packages/web3-utils/src/Utils.js | ||
/** | ||
* Returns a `Boolean` on whether or not the a `String` starts with '0x' | ||
* @param {String} str the string input value | ||
* @return {Boolean} a boolean if it is or is not hex prefixed | ||
* @throws if the str input is not a string | ||
*/ | ||
const isHexPrefixed = str => { | ||
if (typeof str !== 'string') { | ||
throw new Error('[is-hex-prefixed] value must be type string'); | ||
} | ||
return str.slice(0, 2).toLowerCase() === '0x'; | ||
}; | ||
/** | ||
* Removes '0x' from a given `String` if present | ||
* @param {String} str the string value | ||
* @return {String|Optional} a string by pass if necessary | ||
*/ | ||
const stripHexPrefix = str => { | ||
if (typeof str !== 'string') { | ||
return str; | ||
} | ||
return isHexPrefixed(str) ? str.slice(2) : str; | ||
}; | ||
/** | ||
* Returns true if object is BN, otherwise false | ||
@@ -411,2 +438,4 @@ * | ||
isBigNumber, | ||
isHexPrefixed, | ||
stripHexPrefix, | ||
utf8ToHex, | ||
@@ -413,0 +442,0 @@ hexToUtf8, |
{ | ||
"name": "@arcblock/forge-util", | ||
"version": "0.12.2", | ||
"version": "0.12.3", | ||
"description": "utils shared across mutlipe forge js libs, works in both node.js and browser", | ||
@@ -45,3 +45,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "56a2e548c7abc10ce76a96c259b7a6b2cd11148e" | ||
"gitHead": "750553ccecfb063e55f5a62d721b6c3553678bcf" | ||
} |
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
13670
418