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

meg-rc

v4.0.0

Published

A simple radix converter.

Downloads

6

Readme

RadixConverter

A simple radix converter.

Features

Converts any radix to any radix.

Installation

npm install meg-rc

Usage

decimal <-> base 52

import RadixConverter from "meg-rc";

const numerals  = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
const converter = new RadixConverter(numerals);

converter.fromDecimal(123456789);  // 8m0Kx
converter.intoDecimal("8m0Kx");    // 123456789

base 7 <-> base 3

import RadixConverter from "meg-rc";

const base7 = new RadixConverter("0123456");
const base3 = new RadixConverter("012");

let a = base7.fromDecimal(12345);     // 12345(10) => 50664(7)
let b = base7.convertInto(base3)(a);  // 50664(7) => 121221020(3)
let c = base3.intoDecimal(b);         // 121221020(3) => 12345(10)

base 9 <-> base 4 (variant)

import RadixConverter from "meg-rc";

const base9 = new RadixConverter("012345678");
const base4 = new RadixConverter("four");

let a = base9.fromDecimal(6789);      // 6789(10) => 10273(9)
let b = base4.convertFrom(base9)(a);  // 10273(9) => ouuufoo(4)
let c = base4.intoDecimal(b);         // ouuufoo(4) => 6789(10)

base4.intoDecimal("fouuufoo");  // 6789

Reuse of converter (base 6 -> base 8)

import RadixConverter from "meg-rc";

const base6 = new RadixConverter("012345");
const base8 = new RadixConverter("01234567");
 
const convert68 = base6.convertInto(base8);  // base 6 => base 8 conversion function
 
let a = base6.fromDecimal(1357);  // 1357(10) => 10141(6)
let b = base6.fromDecimal(2468);  // 2468(10) => 15232(6)
 
a = convert68(a);  // 10141(6) => 2515(8)
b = convert68(b);  // 15232(6) => 4644(8)
 
base8.intoDecimal(a);  // 2515(8) => 1357(10)
base8.intoDecimal(b);  // 4644(8) => 2468(10)

Use multiple characters as one numeral

import RadixConverter from "meg-rc";

// pass numerals as array
const converter = new RadixConverter(["ba", "bana", "banana"]);

let a = converter.fromDecimal(123);  // banabanabanabananaba
let b = converter.intoDecimal(a);    // 123

Use Emoji

import RadixConverter from "meg-rc";

// these emoji are made up of multiple characters
const converter = new RadixConverter(["🧑", "🧑🏻", "🧑🏼", "🧑🏽", "🧑🏾", "🧑🏿"]);

let a = converter.fromDecimal(11190);  // 🧑🏻🧑🏼🧑🏽🧑🏾🧑🏿🧑
let b = converter.intoDecimal(a);      // 11190

Disable validation

import RadixConverter from "meg-rc";

// validation disabled (nothing happens)
new RadixConverter(["1", "2", "12"], false);

// validation enabled (throws TypeError)
// Invalid numerals: 12 and 2 cannot be used together 
new RadixConverter(["1", "2", "12"]);