MCPcopy Create free account
hub / github.com/electric-sql/electric / hexStringToUint8Array

Function hexStringToUint8Array

examples/yjs/src/client/common/utils.ts:3–10  ·  view source on GitHub ↗
(hexString: string)

Source from the content-addressed store, hash-verified

1import * as decoding from "lib0/decoding"
2
3const hexStringToUint8Array = (hexString: string) => {
4 const cleanHexString = hexString.startsWith(`\\x`)
5 ? hexString.slice(2)
6 : hexString
7 return new Uint8Array(
8 cleanHexString.match(/.{1,2}/g)!.map((byte) => parseInt(byte, 16))
9 )
10}
11
12export const parseToDecoder = {
13 bytea: (hexString: string) => {

Callers 1

utils.tsFile · 0.70

Calls 2

sliceMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected