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

simple-base-converter

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-base-converter

Simple math module for base conversion.

  • 1.0.19
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
361
decreased by-34.95%
Maintainers
1
Weekly downloads
 
Created
Source

simple-base-converter

master:

Simple math module for base conversion.

Install

npm i simple-base-converter

Usage

Some bases(2, 8, 16, 32, 36, 62) are predefined.

  • _10To2(num)
  • _10To8(num)
  • _10To16(num)
  • _10To32(num)
  • _10To36(num)
  • _10To62(num)
  • _2To10(num)
  • _8To10(num)
  • _16To10(num)
  • _32To10(num)
  • _36To10(num)
  • _62To10(num)
import { _10To2, _2To10 } from "simple-base-converter";

_10To2(100); // "1100100"
_2To10(1100100); // "100"

// Input can be both integer or string number.
_10To2("100"); // "1100100"
_2To10("1100100"); // "100"

Of course you can choose bases freely.
convertBase(num, originalBase, newBase) converts num from originalBase to newBase.
If you set integer to originalBase or newBase, they are automatically converted by using default base 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.

import { convertBase } from "simple-base-converter";

convertBase("20a4", 17, 52); // "3Ag"
convertBase("20a4", "0123456789abcdefg", "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP"); // "3Ag"

Custom bases are also available.

convertBase(10000, 10, "-・"); // "・--・・・---・----"
convertBase("4649", "0123456789", "零一二三四五六七八九"); // "四六四九"

Keywords

FAQs

Package last updated on 19 Jun 2023

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