Socket
Socket
Sign inDemoInstall

any-base

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    any-base

Converter from any base to other any base


Version published
Weekly downloads
1.3M
increased by2.95%
Maintainers
1
Install size
14.6 kB
Created
Weekly downloads
 

Readme

Source

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'

Keywords

FAQs

Last updated on 09 Oct 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc