1.0.0 • Published 7 years ago

basechanger v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

basechanger Build Status

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.