@imhele/radix
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

radix

NPM version NPM downloads Build Status Coverage Status License

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`

Readme

Keywords

Package Sidebar

Install

npm i @imhele/radix

Weekly Downloads

6

Version

2.0.0

License

MIT

Unpacked Size

9.07 kB

Total Files

7

Last publish

Collaborators

  • imhele