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

bb26

v4.0.0

Published

Utilities for working with bijective base-26 numerals

Downloads

1,150

Readme

BB26

Badge indicating number of weekly downloads of BB26 from npm package registry Badge indicating percent test coverage of BB26

BB26 is a JavaScript library for working with bijective base-26 (BB26) numbers

What is bijective base-26 numeration?

You’re probably familiar with BB26 numeration. It’s used for spreadsheet columns, license plate serials, and (probably?) more.

Here’s an example of decimal (base-10) numbers (the numbers you use every day to count things) compared to their corresponding BB26 numbers:

Decimal: | 1 | 2 | 3 | ... | 24 | 25 | 26 | 27 | 28 | 29 | ...
   BB26: | A | B | C | ... |  X |  Y |  Z | AA | AB | AC | ...

Install

Note

This package is a native ECMAScript Module (ESM). If your project is not ESM, read Sindre Sorhus’s Pure ESM package article.

npm install bb26

API

increment()

function increment(string: string): string;

Increments a bijective base-26 string by one numeral.

import { increment } from "bb26";

increment("A");  // 'B'
increment("Z");  // 'AA'
increment("AA"); // 'AB'

random()

function random(upper: string): string;
function random(lower: string, upper: string): string;

Produces a random string between the inclusive lower and upper bounds. If only one argument is provided, a string between 'A' and the given string is returned.

import { random } from "bb26";

random("AAA");         // 'NE'
random("AAA", "AAAA"); // 'KXZ'

range()

function range(end: string): string[];
function range(start: string, end: string): string[];

Creates an array of bijective base-26 numerals progressing from start up to, but not including, end. If end is not specified, it's set to start with start then set to 'A'.

import { range } from "bb26";

range("B");       // ['A']
range("C");       // ['A', 'B']
range("B", "C");  // ['B']
range("B", "D");  // ['B', 'C']
range("Z", "AC"); // ['Z', 'AA', 'AB']

toBb26()

function toBb26(number: number): string;

Converts a decimal number to a bijective base-26 string.

import { toBb26 } from "bb26";

toBb26(1);  // 'A'
toBb26(2);  // 'B'
toBb26(26); // 'Z'
toBb26(27); // 'AA'
toBb26(28); // 'AB'

toDecimal()

function toDecimal(string: string): number;

Converts a bijective base-26 string to a decimal number.

import { toDecimal } from "bb26";

toDecimal("A");  // 1
toDecimal("B");  // 2
toDecimal("Z");  // 26
toDecimal("AA"); // 27
toDecimal("AB"); // 28