JSPM

b64u-lite

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 142216
  • Score
    100M100P100Q167785F
  • License MIT

isomorphic base64url library in 244 bytes

Package Exports

  • b64u-lite
  • b64u-lite/bundle/b64u-lite

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (b64u-lite) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

b64u-lite NPM Build

isomorphic base64url library in 244 bytes

Usage

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

b64u.toBase64Url('hi there? 你好');
// aGkgdGhlcmU_IOS9oOWlvQ

// add padding
b64u.toBase64Url('hi there? 你好', true);
// aGkgdGhlcmU_IOS9oOWlvQ==

// works with or without padding
b64u.fromBase64Url('aGkgdGhlcmU_IOS9oOWlvQ==');
b64u.fromBase64Url('aGkgdGhlcmU_IOS9oOWlvQ');
// hi there? 你好

// equivalent to btoa
b64u.fromBinaryString('hi there? ');
// aGkgdGhlcmU_IA

// with padding
b64u.fromBinaryString('hi there? ', true);
// aGkgdGhlcmU_IA==

// equivalent to atob
b64u.toBinaryString('aGkgdGhlcmU=');
// hi there? 

Can it be smaller?

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

import { toBase64Url } from 'b64u-lite'

License

MIT