Encodes a number to a letter representation, or decodes it back
npm install alphanumeric-encoder



---




!Vulnerabilities



---
Table of Contents
- :book: Getting Started
- Purpose
- Install as an NPM Package
- Use in Javascript
- :gear: API Documentation
- :hammer_and_wrench: Node and Operating System Support Policy
- :clipboard: License and Development
- :envelope: Contact
---
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)
``javascript`
npm install alphanumeric-encoder
`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]
`
---
See the API for more detailed information on how to use the class.
The test suite has successfully run on all combinations of:
- 
- !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.
---
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 :star2: if you find this project useful!
Maintained by M. Scott Lassiter.



