Skip to main content

parseHex

Midnight.js API Reference v2.0.2


Midnight.js API Reference / @midnight-ntwrk/midnight-js-utils / parseHex

Function: parseHex()

parseHex(source): ParsedHexString

Parses a string as a hex-encoded string.

Parameters

source

string

The source string to parse.

Returns

ParsedHexString

A ParsedHexString describing the parsed elements of source.

Examples

parseHex('Hello') =>
{
hasPrefix: false,
incompleteChars: 'Hello'
}
parseHex('ab12e') =>
{
hasPrefix: false,
byteChars: 'ab12'
incompleteChars: 'e'
}
parseHex('0xab12') =>
{
hasPrefix: true,
byteChars: 'ab12'
incompleteChars: ''
}