1.0.3 • Published 5 years ago

hex-string v1.0.3

Weekly downloads
105
License
Public domain
Repository
github
Last release
5 years ago

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 bench

4096 trials, 1024 bytes per trial
encode (node Buffer): 20.834ms
decode (node Buffer): 16.737ms
encode (toString): 502.201ms
decode (parseInt): 317.031ms
encode (this module): 37.162ms
decode (this module): 56.636ms

How

Do maths in plain JavaScript.

Test

$ npm run test

Notes

  • Tested against node's Buffer for compatibility
  • Decode returns Uint8Array instead of Buffer

License

Public Domain

1.0.3

5 years ago

1.0.2

6 years ago

1.0.1

8 years ago

1.0.0

8 years ago