TS utility for converting an input from any base to another base the min base this library accepts is 2 and max base is 36.
npm i @nodecfdi/utils-internal-baseconverter --save
or
yarn add @nodecfdi/utils-internal-baseconverter
The converter expects 3 parameters: converter.convert(input, fromBase, toBase)
import { BaseConverter } from '@nodecfdi/utils-internal-baseconverter';
// this is the main reason to exists of BaseConverter class
// since parseInt and toString cannot handle large inputs
const input = '3330303031303030303030333030303233373038';
const converter = BaseConverter.createBase36();
// result will be: 292233162870206001759766198425879490508935868472
const result = converter.convert(input, 16, 10);
alternatively you can define your own sequence:
import { BaseConverter, BaseConverterSequence } from '@nodecfdi/utils-internal-baseconverter';
const hexSequence = new BaseConverterSequence('0123456789ABCDEF');
const converter = new BaseConverter(hexSequence);
const input = 'FFFF';
// resut will be: 1111111111111111
converter.convert(input, 16, 2);
Generated using TypeDoc