@exromany/lido-csm-sdk
Version:
[](https://github.com/lidofinance/lido-csm-sdk/blob/main/LICENSE.txt) [](h
27 lines • 1.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeTrimHex = exports.toHexString = exports.trimHexPrefix = exports.isHexadecimalString = void 0;
const isHexadecimalString = (input, length) => {
if (typeof input !== 'string')
return false;
const normalizedInput = (0, exports.trimHexPrefix)(input);
const isValid = /^[0-9a-fA-F]+$/.test(normalizedInput);
if (length !== undefined) {
return isValid && normalizedInput.length === length;
}
return isValid;
};
exports.isHexadecimalString = isHexadecimalString;
const trimHexPrefix = (input) => {
return input.startsWith('0x') ? input.slice(2) : input;
};
exports.trimHexPrefix = trimHexPrefix;
const toHexString = (text) => {
return text.startsWith('0x') ? text : `0x${text}`;
};
exports.toHexString = toHexString;
const normalizeTrimHex = (hex) => {
return (0, exports.trimHexPrefix)(hex).toLowerCase();
};
exports.normalizeTrimHex = normalizeTrimHex;
//# sourceMappingURL=is-hexadecimal-string.js.map