any-base
Converter from any base to other any base
Last updated 7 years ago by mifczu .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install any-base 
SYNC missed versions from official npm registry.

README

The library allows you to convert any large numbers in any number base to another number base. The base is determined by specifying the alphabet. So is full freedom

NPM

Installation

npm install any-base --save

API

AnyBase()

converterFunction = anyBase(sourceAlphabet, destinationAlphabet);

Parameters

  • {String} sourceAlphabet digits from smallest to the largest
  • {String} destinationAlphabet digits from smallest to the largest

Return Values

Returns function that converts the number of source base to the destination

Convert()

converterFunction(number)

Parameters

  • {String} number number of source base

Return Values

Returns number of destonation base

Example

var anyBase = require('any-base'),
dec2hex = anyBase(anyBase.DEC, anyBase.HEX),
shortId = anyBase(anyBase.DEC, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-+!@#$^'),
longId  = anyBase('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-+!@#$^', anyBase.DEC);

dec2hex('123456'); // return: '1E240'
shortId('1234567890'); // return: 'PtmIa'
longId('PtmIa'); // return: '1234567890'

Current Tags

  • 1.1.0                                ...           latest (7 years ago)

3 Versions

  • 1.1.0                                ...           7 years ago
  • 1.0.1                                ...           8 years ago
  • 1.0.0                                ...           9 years ago
Maintainers (1)
Downloads
Total 3
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (4)

© 2010 - cnpmjs.org x YWFE | Home | YWFE