UNPKG

555 BJavaScriptView Raw
1'use strict';
2var commonAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
3var base64Alphabet = commonAlphabet + '+/';
4var base64UrlAlphabet = commonAlphabet + '-_';
5
6var inverse = function (characters) {
7 // TODO: use `Object.create(null)` in `core-js@4`
8 var result = {};
9 var index = 0;
10 for (; index < 64; index++) result[characters.charAt(index)] = index;
11 return result;
12};
13
14module.exports = {
15 i2c: base64Alphabet,
16 c2i: inverse(base64Alphabet),
17 i2cUrl: base64UrlAlphabet,
18 c2iUrl: inverse(base64UrlAlphabet)
19};