Package Exports
- base-p
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 (base-p) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Install
npm install base-pUsage
const Base = require('base-p')
base62 = new Base(62)
base62.encode(2017) // returns 'WX'
base62.decode('WX') // returns 2017
base5 = new Base('01234')
base5.encode(7) // returns '12'
base5.decode('12') // returns 7Usage with BigInt
const Base = require('base-p')
base62 = new Base(62)
base62.encodeBig(2017n) // returns 'WX'
base62.decodeBig('WX') // returns 2017n
base5 = new Base('01234')
base5.encodeBig(7n) // returns '12'
base5.decodeBig('12') // returns 7nBase
The parameter for the constructor is a either a string containing the alphabet used for the conversion, or an integer representing the base for one of the predefined alphabets:
| Base | Alphabet |
|---|---|
| 2 | 01 |
| 8 | 01234567 |
| 11 | 0123456789a |
| 16 | 0123456789abcdef |
| 32 | 0123456789ABCDEFGHJKMNPQRSTVWXYZ |
| 36 | 0123456789abcdefghijklmnopqrstuvwxyz |
| 58 | 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz |
| 62 | 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |
| 64 | ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ |
| 67 | ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.!~ |