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

Function hexStringToUint8Array

packages/y-electric/src/utils.ts:6–13  ·  view source on GitHub ↗
(hexString: string)

Source from the content-addressed store, hash-verified

4 * Convert a hex string from PostgreSQL's bytea format to a Uint8Array
5 */
6const hexStringToUint8Array = (hexString: string) => {
7 const cleanHexString = hexString.startsWith(`\\x`)
8 ? hexString.slice(2)
9 : hexString
10 return new Uint8Array(
11 cleanHexString.match(/.{1,2}/g)!.map((byte) => parseInt(byte, 16))
12 )
13}
14
15/**
16 * Utility to parse hex string bytea data to a decoder for YJS operations

Callers 1

utils.tsFile · 0.70

Calls 2

sliceMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected