15 lines
359 B
JavaScript
15 lines
359 B
JavaScript
var isHexPrefixed = require('is-hex-prefixed');
|
|
|
|
/**
|
|
* Removes '0x' from a given `String` is present
|
|
* @param {String} str the string value
|
|
* @return {String|Optional} a string by pass if necessary
|
|
*/
|
|
module.exports = function stripHexPrefix(str) {
|
|
if (typeof str !== 'string') {
|
|
return str;
|
|
}
|
|
|
|
return isHexPrefixed(str) ? str.slice(2) : str;
|
|
}
|