npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

base2base

v1.1.0

Published

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

Downloads

11

Readme

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