python-archieve-projects/WechatBot/node_modules/any-base
Lee2vv 0b82373111 init 2024-05-05 13:46:50 +08:00
..
dist init 2024-05-05 13:46:50 +08:00
src init 2024-05-05 13:46:50 +08:00
LICENSE Backup 2023-08-18 21:52:54 +08:00
README.md Backup 2023-08-18 21:52:54 +08:00
index.js init 2024-05-05 13:46:50 +08:00
package.json Backup 2023-08-18 21:52:54 +08:00

README.md

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'