MCPcopy Create free account
hub / github.com/LibPDF-js/core / hexToBytes

Function hexToBytes

src/test-utils.ts:161–170  ·  view source on GitHub ↗
(hex: string)

Source from the content-addressed store, hash-verified

159 * ```
160 */
161export function hexToBytes(hex: string) {
162 const cleaned = hex.replace(/\s/g, "");
163 const bytes = new Uint8Array(cleaned.length / 2);
164
165 for (let i = 0; i < bytes.length; i++) {
166 bytes[i] = Number.parseInt(cleaned.slice(i * 2, i * 2 + 2), 16);
167 }
168
169 return bytes;
170}
171
172/**
173 * Check if bytes start with the PDF header signature.

Callers 1

index.test.tsFile · 0.90

Calls 2

parseIntMethod · 0.80
sliceMethod · 0.80

Tested by

no test coverage detected