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

base73

v1.0.0

Published

Base73 Encoding and Decoding.

Downloads

4

Readme

Base73

A lightweight JavaScript implementation of the base73 encoding method.

Base73 uses a set of 73 ASCII characters, where binary data is taken 7 bits at a time, and mapped to each character. Since 2^7 is equal to 128, the first 54 characters of the set contain secondary values, that can be accessed by prefixing with the secondary access character. The secondary access character is ^ (ASCII 94). If the encoded data is not divisible by 8, padding is added, determined by how many characters are missing to reach the next multiple of 8. The padding character is = (ASCII 61).

Getting Started

To get started, install the library:

npm install base73

The library can handle Unit8Array, Buffer, Hexadecimal, String, Decimal, and Binary data types. All encoding and decoding can be completed using the base73 function.

  • base73.Unit8Array.from()
  • base73.toUnit8Array()
  • base73.buffer.from()
  • base73.toBuffer()
  • base73.hex.from()
  • base73.toHex()
  • base73.string.from()
  • base73.toString()
  • base73.decimal.from()
  • base73.toDecimal()
  • base73.binary.from()
  • base73.toBinary()

Usage

First, require the module:

const base73 = require('base73');

The following example shows how you can convert between a string and a base73 encoded string:

const base73 = require('base73');

const string = "Nothing Matters.";
console.log("Encoded String:", base73.string.from(string));

// Example Output
// Encoded String: TH^RxuR^@^K9@YDP^1^#^Vk^$r======

This next example shows conversion from base73 encoded strings, to Unit8Arrays and Hexadecimal:

const base73 = require('base73');

const encodedString = "TH^RxuR^@^K9@YDP^1^#^Vk^$r======";

console.log("Unit8Array:", base73.toUnit8Array(encodedString));
console.log("Hexadecimal:", base73.toHex(encodedString));

// Example output
// Unit8Array: Uint8Array(16) [78, 111, 116, 104, 105, 110, 103, 32, 77, 97, 116, 116, 101, 114, 115, 46]
// Hexadecimal: 4e6f7468696e67204d6174746572732e

Character Set

The base73 character set is based on 73 ASCII characters. Alongside this is also the use of the secondary access character ^, and the padding character =, making for a total extended set size of 75.

const base73CharSet = [
    33, 35, 36, 37, 38, 43, 45, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 60, 62,
    64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
    83, 84, 85, 86, 87, 88, 89, 90, 95, 97, 98, 99, 100, 101, 102, 103, 104, 105,
    106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
    121, 122,
  ];

// Characters
// !#$%&+-0123456789<>
// @ABCDEFGHIJKLMNOPQR
// STUVWXYZ_abcdefghi
// jklmnopqrstuvwx
// yz