base-conversion
Auto-curried converter between any bases with arbitrary precision support and customisable symbols
Install
npm i base-conversion
Basic usage
var bc = ;var hexToBin = ; ; //=> '1010'; //=> '11110'
See spec.
Custom symbols
For any bases above 62, custom symbols are required. See tests for working examples.
var bc = ; bc; //=> '④Ⓑ'
Symbol translation
To convert between different sets of symbols, use bc.translate
:
var bc = ;var pipe = ; var hexToDuoNormal = ;var hexToDuoCustom = ; ; // => '1A3'; // => '1ᘔ3'
To use it to translate from custom symbols, use bc.translateRaw
:
var mySymbols = '⓿①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮';var myTranslate = bc; var hexToDuoFancy = bc;var hexToDuoCustom = ; ; //=> '①⑩③'; //=> '1ᘔ3'
Arbitrary precision
var bc = ;var Big = ;var toBigFactory = ; var d = ; // avoid large numbers to go into exponential notation (adapter dependent)BigImplE_POS = 50; bc;//=> '802531310452364303450750087576673257456135727727' // equivalent but it skips a trivial decimal to decimal conversionbcfromDecimal;//=> '802531310452364303450750087576673257456135727727'
Full raw version
var bc = ;var Big = ;var toBigFactory = ; var d = ; // avoid large numbers to go into exponential notation (adapter dependent)BigImplE_POS = 50; bc;//=> '802#313104#23643034#07#0087#766732#74#613#727727' // equivalentbcfromDecimal;//=> '802#313104#23643034#07#0087#766732#74#613#727727'
Defaults
The default symbols and big implementation are exposed as follows:
bcdefaultSymbols; //=> '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'bcdefaultB; //=> default arbitrary precision implementation (plus, times, div, mod & pow)