fast64
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/fast64 package

0.5.0 • Public • Published

This immodestly claims to be the fastest in-browser utf-8 safe Base64 decoding library. If you can beat it in the latest version of Chrome, please send a pull request :).

I built it as part of the Superhuman email client, as a significant portion of our CPU-burn goes into Base64 parsing.

It's based on mythic work by DRDigit (Vassilis Petroulias). (I say mythic, because its origins are shrouded in mystery), but uses modern browser features (namely TextEncoder, TextDecoder, Uint8Array, and ArrayBuffer) to beat the original by a very healthy multiplier.

Installation

npm install fast64

Usage

var fast64 = require('base64');
 
// For standard base64
base64 = fast64.encode(string);
string = fast64.decode(base64);
// If you want to decode till Uint8Array and skip the UTF8 decoding.
// This is useful in cases where you need Uint8Array for eg. create blob out of Uint8Array result.
uint8Array = fast64.decode(base64, {uint8Array:true});
 
 
// For URL-safe base64 (-_ in place of +/, and no padding)
base64 = fast64.urlencode(string);
string = fast64.urldecode(base64);
// If you want to decode till Uint8Array and skip the UTF8 decoding.
// This is useful in cases where you need Uint8Array for eg. create blob out of Uint8Array result.
uint8Array = fast64.urldecode(base64, {uint8Array:true});

Testing

If you want to develop this package, you can run the tests in-browser:

npm install
open test/test.html

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.5.0
    1,414
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.5.0
    1,414
  • 0.4.0
    0
  • 0.3.0
    0
  • 0.2.0
    0

Package Sidebar

Install

npm i fast64

Weekly Downloads

1,414

Version

0.5.0

License

Apache

Last publish

Collaborators

  • cirwin