MCPcopy Create free account
hub / github.com/cryptocoinjs/base-x / uint8ArrayFromHexString

Function uint8ArrayFromHexString

test/index.js:11–21  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

9}
10
11const uint8ArrayFromHexString = (string) => {
12 if (!string.length) {
13 return new Uint8Array(0)
14 }
15
16 if (string.length % 2 !== 0) {
17 throw new Error('Invalid hex string')
18 }
19
20 return new Uint8Array(string.match(/.{1,2}/g).map(byte => parseInt(byte, 16)))
21}
22
23const bases = Object.keys(alphabets).reduce(function (bases, alphabetName) {
24 bases[alphabetName] = basex(alphabets[alphabetName])

Callers 1

index.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…