/radix.js

:100: a simple javascript module to convent number to your radix, decimal supported.

Primary LanguageJavaScript

Radix.js

Radix.js is a simple javascript module to convent number to 2-64 radix, decimal supported. 一个用于数字进制转换的 JavaScript 模块,默认支持 2-64 进制(可自定义),支持小数的进制转化

Build Status Coverage Status npm npm npm

1. Install

npm install radix.js

Or download dist/radix.min.js source file.

2. Import It

  • Script tag.
<script type="text/javascript" src="dist/radix.min.js"></script>
  • ES6 style.
var Radix = require('radix.js');

//or

import Radix from 'radix.js';

3. Usage & API

There is only one API named convent.

var radix = new Radix();
radix.convent(5201314, 10, 64); // will convent number 5301314 from radix 10 to radix 64.

Now the max radix is 64, and the formatter is: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@. Also you can set your own formatter like below:

var radix = new Radix('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#');
radix.convent('jRSy', 64);

4. Test

npm install

npm test

5. LICENSE

MIT@hustcc