New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

all-your-base

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

all-your-base

convert from/to binary, hexadecimal, decimal values

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22
decreased by-26.67%
Maintainers
1
Weekly downloads
 
Created
Source

Convert from one base to another

#####Supported bases

base/radixnamemodule's abbr.
base 2binarybin
base 8octaloct
base 10decimaldec
base 16hexadecimalhex

##Installation

npm install all-your-base

##Usage

Use this in your own scripts and/or as a stand-alone command-line tool.

###From a script

decToBin(22);
hexToDec('10000');

#####Parameter data types

to convert from decimal, pass in a non-negative integer
to convert from any base except for decimal, pass in the value as a string

###As command line tool

#####Install as command line tool

npm link from your local repo's root. The executable is named ayb.

#####From command line

ayb decToBin 65536
ayb hexToDec FF001D


###List of all operations

Here's an exhaustive list for your reference.

From binary

  • binToDec
  • binToHex
  • binToOct

From octal

  • octToDec
  • octToBin
  • octToHex

From decimal

  • decToBin
  • decToHex
  • decToOct

From hexadecimal

  • hexToDec
  • hexToBin
  • hexToOct

The pattern: [old]To[New]
[old] is the first three letters of the base you are converting from.
[New] is the first three letters of the base to convert to.

Notice, the function name is lowerCamelCased.


###Helpful links

Learn more about different bases.

  • binary to decimal
  • binary to hexadecimal
  • decimal to binary
  • decimal to hexadecimal
  • hexadecimal to binary or decimal
  • how to understand hexadecimal

Keywords

FAQs

Package last updated on 10 Sep 2015

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc