New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

number-convert

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

number-convert

A function for converting numbers to and from different bases w/o loss of precision.

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

A function for converting numbers to and from different bases w/o loss of precision.

Adapted from http://www.danvk.org/hex2dec.html

The problem is that parseInt("0x12345...") isn't precise enough to convert big integers correctly. This uses strings as input and, internally, arrays as workhorses.

API

This module exports a function, convertBase (this function is the module export), with a few shorthand methods (as properties of the exported function).

convertBase(string input, number fromBase, number toBase) : string

Converts a string representation of a number in base fromBase and converts it into a string respresentation in base toBase. That's it.

hexToDec(string input)

Shorthand for convertBase(input, 16, 10).

decToHex(string input)

Shorthand for convertBase(input, 10, 16).

decToBin(string input)

Shorthand for convertBase(input, 10, 2).

binToDec(string input)

Shorthand for convertBase(input, 2, 10).

hexToBin(string input)

Shorthand for convertBase(input, 16, 2).

binToHex(string input)

Shorthand for convertBase(input, 2, 16).

Keywords

number

FAQs

Package last updated on 18 Mar 2016

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