ethers.js/packages/bytes/lib/check.js

16 lines
497 B
JavaScript
Raw Permalink Normal View History

2022-04-11 17:14:19 -04:00
export function isHexString(value, length) {
if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
return false;
}
if (typeof (length) === "number" && value.length !== 2 + 2 * length) {
return false;
}
if (length === true && (value.length % 2) !== 0) {
return false;
}
return true;
}
export function isBytesLike(value) {
return (isHexString(value, true) || (value instanceof Uint8Array));
}
//# sourceMappingURL=check.js.map