You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

base26

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base26

A simple library to perform basic +/- arithmatic on an alphabet-based number system


Version published
Weekly downloads
278
decreased by-16.01%
Maintainers
1
Created
Weekly downloads
 

Readme

Source
# Base26

A simple library to perform basic +/- arithmatic on an alphabet-based number system.

a + 1 = b
b + 5 = g
z + 1 = aa
abc - 4 = aay

A practical usecase: spreadsheet column names.


---

## API

### base26.add(alpha: string, num: number): string

Increment alpha num times

add('a', 10) -> 'k'
add('aab', 10) -> 'aal'
add('x', 5), -> 'ac'
add('zc', 26), -> 'aac'



### base26.subtract(alpha: string, num: number): string

Decrement alpha num times.  Function throws if the result is not positive.

subtract('f', 5) -> 'a'
subtract('aag', 5) -> 'aab'
subtract('aag', 26) -> 'zg'
subtract('b', 2) -> throws



### base26.from(alpha: string): number

Convert number comprised of lowercase a-z alphabetical digits to the equivalent base10 number

from('a') -> 1
from('z') -> 26
from('aab') -> 704
from('A') -> throws
from('1') -> throws



### base26.to(decimal: number): string

Convert positive base10 number (> 0) to alphabetical digits

to(1) -> 'a'
to(26) -> 'z'
to(704) -> 'aab'
to(0) -> throws
to(-10) -> throws

FAQs

Package last updated on 07 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc