package
Converter from any base to other any base
npm install any-baseGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
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 install any-base --saveconverterFunction = anyBase(sourceAlphabet, destinationAlphabet);Returns function that converts the number of source base to the destination
converterFunction(number)Returns number of destonation base
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'