You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
555 B
20 lines
555 B
'use strict';
|
|
var commonAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
var base64Alphabet = commonAlphabet + '+/';
|
|
var base64UrlAlphabet = commonAlphabet + '-_';
|
|
|
|
var inverse = function (characters) {
|
|
// TODO: use `Object.create(null)` in `core-js@4`
|
|
var result = {};
|
|
var index = 0;
|
|
for (; index < 64; index++) result[characters.charAt(index)] = index;
|
|
return result;
|
|
};
|
|
|
|
module.exports = {
|
|
i2c: base64Alphabet,
|
|
c2i: inverse(base64Alphabet),
|
|
i2cUrl: base64UrlAlphabet,
|
|
c2iUrl: inverse(base64UrlAlphabet)
|
|
};
|