b64-lite
isomorphic base64 library in 152 bytes
Last updated a year ago by kevlened .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install b64-lite 
SYNC missed versions from official npm registry.

b64-lite NPM Build bundlephobia

Node, browser, and React Native base64 library

Usage

const b64 = require('b64-lite');

// Base64 in ASCII to byte string
b64.atob('aGkgdGhlcmU=');
// hi there

// byte string to Base64 in ASCII
b64.btoa('hi there');
// aGkgdGhlcmU=

// convert unicode to b64
b64.toBase64('hello 你好');
// aGVsbG8g5L2g5aW9

// convert a buffer to b64
b64.toBase64(new Uint8Array([228, 189, 160, 229, 165, 189]).buffer);
// 5L2g5aW9

// decode b64 to unicode
b64.fromBase64('aGVsbG8g5L2g5aW9');
// hello 你好

// convert b64 to a buffer
b64.toBuffer('5L2g5aW9');
// new Uint8Array([228, 189, 160, 229, 165, 189]).buffer

Can it be smaller?

If you use ES6 imports with a bundler that supports tree-shaking, yes!

import { toBase64 } from 'b64-lite'

License

MIT

Current Tags

  • 1.4.0                                ...           latest (a year ago)

9 Versions

  • 1.4.0                                ...           a year ago
  • 1.3.1                                ...           3 years ago
  • 1.3.0                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
  • 0.0.1                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 23
This Month 119
Last Day 18
Last Week 37
Last Month 136
Dependencies (1)
Dev Dependencies (8)

Copyright 2014 - 2016 © taobao.org |