2020-05-16 00:42:02 +02:00
|
|
|
import Utils from "../Utils.mjs";
|
|
|
|
|
2018-08-22 20:24:32 +01:00
|
|
|
/**
|
|
|
|
* Base85 resources.
|
|
|
|
*
|
|
|
|
* @author PenguinGeorge [george@penguingeorge.com]
|
|
|
|
* @copyright Crown Copyright 2018
|
|
|
|
* @license Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base85 alphabet options.
|
|
|
|
*/
|
|
|
|
export const ALPHABET_OPTIONS = [
|
|
|
|
{
|
|
|
|
name: "Standard",
|
2024-02-25 16:31:23 -05:00
|
|
|
value: "!-u"
|
2018-08-22 20:24:32 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Z85 (ZeroMQ)",
|
2024-02-25 16:31:23 -05:00
|
|
|
value: "0-9a-zA-Z.\\-:+=^!/*?&<>()[]{}@%$#"
|
2018-08-22 20:24:32 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "IPv6",
|
2024-02-25 16:31:23 -05:00
|
|
|
value: "0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|}~"
|
2024-02-25 16:23:48 -05:00
|
|
|
}
|
2018-08-22 20:24:32 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the name of the alphabet, when given the alphabet.
|
|
|
|
*
|
|
|
|
* @param {string} alphabet
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
export function alphabetName(alphabet) {
|
2020-05-16 00:42:02 +02:00
|
|
|
alphabet = escape(alphabet);
|
2018-08-22 20:24:32 +01:00
|
|
|
let name;
|
|
|
|
|
2024-02-25 16:31:23 -05:00
|
|
|
ALPHABET_OPTIONS.forEach(function (a) {
|
2020-05-16 00:42:02 +02:00
|
|
|
const expanded = Utils.expandAlphRange(a.value).join("");
|
|
|
|
if (alphabet === escape(expanded)) name = a.name;
|
2018-08-22 20:24:32 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|