hex-string
Fast hex / binary transcoding in pure JavaScript.
Why
Not as fast as node's implementation, but quite a bit faster than using toString(16)
and parseInt(n, 16)
which is generally what's used in the browser.
On my laptop, using node@10.12.0:
$ npm run bench> hex-string@1.0.0 bench hex-string> node bench4096 trials, 1024 bytes per trialencode : 20.834msdecode : 16.737msencode : 502.201msdecode : 317.031msencode : 37.162msdecode : 56.636ms
How
Do maths in plain JavaScript.
Test
$ npm run test
Notes
- Tested against node's Buffer for compatibility
- Decode returns
Uint8Array
instead ofBuffer
License
Public Domain