MCPcopy Create free account
hub / github.com/PageLeay/celestial-runtime / isHexString

Function isHexString

src.ts/utils/data.ts:77–86  ·  view source on GitHub ↗
(value: any, length?: number | boolean)

Source from the content-addressed store, hash-verified

75 * bytes of data (e.g. ``0x1234`` is 2 bytes).
76 */
77export function isHexString(value: any, length?: number | boolean): value is `0x${ string }` {
78 if (typeof(value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
79 return false
80 }
81
82 if (typeof(length) === "number" && value.length !== 2 + 2 * length) { return false; }
83 if (length === true && (value.length % 2) !== 0) { return false; }
84
85 return true;
86}
87
88/**
89 * Returns true if %%value%% is a valid representation of arbitrary

Callers 2

isBytesLikeFunction · 0.70
dataLengthFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected