@imhele/radix
v2.0.0
Published
[![NPM version](https://img.shields.io/npm/v/@imhele/radix.svg?style=flat)](https://npmjs.org/package/@imhele/radix) [![NPM downloads](http://img.shields.io/npm/dm/@imhele/radix.svg?style=flat)](https://npmjs.org/package/@imhele/radix) [![Build Status](ht
Downloads
20
Readme
radix
Install
$ npm install @imhele/radix --save
or
$ yarn add @imhele/radix
Exmaple
import changeRadix from '@imhele/radix';
changeRadix('2', { fromRadix: 10, toRadix: 2 });
// '10'
changeRadix('FFFF', { fromRadix: 16, toRadix: 32 });
// '1VVV'
changeRadix(12345678, { fromRadix: 10 });
// 'pnfq'
changeRadix('12345678', { fromRadix: 10, toCharMap: '0123456789abcdef' });
// 'bc614e'
Throw error
Does not suport decimal.
changeRadix(1.2);
// ERROR:
// [radix] The input message `1.1` include the char `.`
// that does not exist in char map `0123456789abcde...`
changeRadix(2, { toRadix: 1 });
changeRadix(2, { toRadix: 2.2 });
changeRadix(2, { toRadix: 100, toCharMap: '01' });
// ERROR:
// [radix] The radix must be an integer between `2`
// and `charMap.length (62)`, but got `1`