thedesk/app/node_modules/any-base/index.js

30 lines
696 B
JavaScript
Raw Permalink Normal View History

2019-09-13 00:38:13 +10:00
var Converter = require('./src/converter');
/**
* Function get source and destination alphabet and return convert function
*
* @param {string|Array} srcAlphabet
* @param {string|Array} dstAlphabet
*
* @returns {function(number|Array)}
*/
function anyBase(srcAlphabet, dstAlphabet) {
var converter = new Converter(srcAlphabet, dstAlphabet);
/**
* Convert function
*
* @param {string|Array} number
*
* @return {string|Array} number
*/
return function (number) {
return converter.convert(number);
}
};
anyBase.BIN = '01';
anyBase.OCT = '01234567';
anyBase.DEC = '0123456789';
anyBase.HEX = '0123456789abcdef';
module.exports = anyBase;