from Hacker News

Faster-than-native toHex() for JavaScript Uint8Arrays

by gmac on 11/13/24, 4:38 PM with 1 comments

  • by gmac on 11/13/24, 4:40 PM

    Firefox 133b7 and Safari Tech Preview both have a new Uint8Array.toHex() method, but otherwise browsers don't yet have a native way to turn binary data into hex strings.

    I put this tiny package together to fill this gap using a significantly faster technique than I've seen elsewhere.

    Surprisingly, it's actually faster than the current native Firefox implementation (at least on a recent MacBook Pro). Hopefully that won't remain the case for too much longer ...