Socket
Book a DemoInstallSign in
Socket

base2base

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base2base

A node.js typescript function to convert any string/number, from & to all the bases ranging between 2-36 and base64.

1.1.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

base2base

A node.js typescript function to convert any string/number, from & to all the bases ranging between 2-36 and base64.

 

How to use

const base2base = require("base2base")


let binary = base2base(314159, {to: 2})
console.log(binary)
// "1001100101100101111"

let hex = base2base(binary, {from: 2, to: 16})
console.log(hex)
// "4cb2f"

let base64 = base2base(hex, {to: 64})
console.log(base64)
// "NGNiMmY="

let hexDecoded = base2base(base64, {from: 64})
console.log(hexDecoded)
// "4cb2f"


let invalidBinary = base2base("1010ab", {from: 2, to: 2})
console.log(invalidBinary)
// "1010"

let invalidBinaryStrict = base2base("1010ab", {from: 2, to: 2, strict: true})
console.log(invalidBinaryStrict)
// NaN

 

Changelog & Breaking Changes

  • v1.0.0
    - First commit.
    • v1.0.1
      - Fixed bug where Intellisense wouldn't work.
  • v1.1.0
    - Added strict mode for base64 as well.

 

Found a bug and/or need help?

Please open an issue on GitHub to request a change, report a bug or ask for help about something and i will gladly look into it.

If you like this library, consider giving it a star on GitHub. It means a lot :)

Keywords

base

FAQs

Package last updated on 04 Sep 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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.