basechanger
v1.0.0
Published
Switch the base of numbers dynamically
Downloads
4
Readme
basechanger
Switch the base of numbers dynamically
Installation
npm i basechanger --save
Usage
const basechanger = require('basechanger');
// Encode a number to hex
console.log(basechanger.encode(42, basechanger.alphabets.hex)); // 2A
// Define your own alphabet
const custom = [
'g', 'h', '7', '4', 'z'
];
console.log(basechanger.encode(42, custom)); // h47
Existing alphabets
The following alphabets are existing:
- Binary
0 1
- Octal
0 1 ... 7
- Decimal
0 1 ... 9
- Hexadecimal
0 1 ... F
Select them using the basechanger.alphabets
key.