Skip to content

M-Scott-Lassiter/Alphanumeric-Encoder

Repository files navigation

Alphanumeric Encoder

NPM Version NPM Package Size License


Tests Build codecov Dependency status Vulnerabilities Open Issues

Maintained contributions welcome


Table of Contents

πŸ“– Getting Started

Purpose

alphanumeric-encoder is a lightweight library with no dependencies. It can encode an integer into a letter representation, decode the letter back into a number, and deconstruct combined strings of letters and numbers into an array of decoded numbers.

This is useful for converting letter indexes (used by people) to numbers (used by computers). Examples include:

  • Spreadsheet columns (e.g. Microsoft Excel's end column is "XFD" which corresponds to 16384)
  • Game boards (e.g. Chess, Battleship) use letters and numbers to identify the grid
  • Geodesy grid reference systems (e.g. the United States National Grid)

Install as an NPM Package

npm install alphanumeric-encoder

Use in Javascript

const AlphanumericEncoder = require('alphanumeric-encoder')

const encoder = new AlphanumericEncoder()

console.log(encoder.encode(5)) // 'E'
console.log(encoder.encode(48)) // 'AV'
console.log(encoder.encode(733)) // 'ABE'

console.log(encoder.decode('A')) // 1
console.log(encoder.decode('AC')) // 29
console.log(encoder.decode('ANE')) // 1045

console.log(encoder.deconstruct('C7')) // [3, 7]
console.log(encoder.deconstruct('AC22')) // [29, 22]
console.log(encoder.deconstruct('C3ABC123EFGH456')) // [3, 3, 731, 123, 92126, 456]

βš™οΈ API Documentation

See the API for more detailed information on how to use the class.

πŸ› οΈ Node and Operating System Support Policy

The test suite has successfully run on all combinations of:

  • Node Versions Supported
  • Windows Supported Mac Supported Linux Supported

This project supports Long-Term Support, Current, and Maintenance versions of node. Once a version reaches end of life, the CI scripts will no longer support them. Odd Node versions will only receive support while in a current status.

Other Node versions and operating systems might support the library, but the tests have not verified other combinations.


πŸ“‹ License and Development

alphanumeric-encoder and all other files in this repository are distributed as free and open-source software under the MIT License, Β© 2022.

Both contributions and bug reports welcome. See the change log for specific details of each release.

Leave a 🌟 if you find this project useful!

βœ‰οΈ Contact

Maintained by M. Scott Lassiter.

GitHub Badge Profile Twitter Badge Profile LinkedIn Badge Profile Stackoverflow Badge Profile