base2base
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

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 :)

Readme

Keywords

Package Sidebar

Install

npm i base2base

Weekly Downloads

9

Version

1.1.0

License

MIT

Unpacked Size

8.46 kB

Total Files

9

Last publish

Collaborators

  • zwolfrost