ethers.js/packages/bytes/lib/check.js
2022-04-17 04:31:42 -04:00

16 lines
497 B
JavaScript

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