number-to-alphabet
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Number-To-Alphabet

Convert a number to a string and vice versa, using the provided alphabet (or default of a-z).

Installation

$ npm install number-to-alphabet

Examples

import { NumberToAlphabet } from 'number-to-alphabet';
 
const defaultAlphabet = new NumberToAlphabet();
defaultAlphabet.numberToString(1);    // 'a'
defaultAlphabet.numberToString(2);    // 'b'
defaultAlphabet.numberToString(27);   // 'aa'
defaultAlphabet.numberToString(28);   // 'ab'
defaultAlphabet.stringToNumber('ab'); // 28
 
const customAlphabet = new NumberToAlphabet(['A', 'B']);
customAlphabet.numberToString(1);    // 'A'
customAlphabet.numberToString(2);    // 'B'
customAlphabet.numberToString(3);    // 'AA'
customAlphabet.numberToString(4);    // 'AB'
customAlphabet.stringToNumber('AB'); // 4

Package Sidebar

Install

npm i number-to-alphabet

Weekly Downloads

756

Version

1.0.0

License

MIT

Unpacked Size

14.1 kB

Total Files

9

Last publish

Collaborators

  • tjenkinson