https://github.com/kevlened/b64-lite
:video_game: isomorphic base64 library in 377 bytes
https://github.com/kevlened/b64-lite
base64 isomorphic javascript small
Last synced: 3 months ago
JSON representation
:video_game: isomorphic base64 library in 377 bytes
- Host: GitHub
- URL: https://github.com/kevlened/b64-lite
- Owner: kevlened
- License: mit
- Created: 2017-12-09T15:31:05.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-29T06:04:09.000Z (almost 3 years ago)
- Last Synced: 2024-08-08T20:53:44.624Z (about 1 year ago)
- Topics: base64, isomorphic, javascript, small
- Language: JavaScript
- Homepage:
- Size: 985 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# b64-lite [](https://npmjs.com/package/b64-lite) [](https://travis-ci.org/kevlened/b64-lite) [](https://bundlephobia.com/result?p=b64-lite)
Node, browser, and React Native base64 library
## Usage
```javascript
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!
```javascript
import { toBase64 } from 'b64-lite'
```## License
MIT