Created
March 24, 2025 19:11
-
-
Save devlongs/084cfe7e13d53b2cb4091988bc75436f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const fromHexString = (inp: Buffer | string): Buffer => { | |
if (typeof inp === 'string') { | |
if (inp.startsWith('0x')) { | |
return Buffer.from(inp.slice(2), 'hex') | |
} | |
return Buffer.from(inp, 'hex') | |
} | |
// If inp is already a Buffer, just return it | |
return inp | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment