# any-base

> Converter from any base to other any base

Latest version **1.1.0** (published 2017-10-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install any-base
pnpm add any-base
yarn add any-base
bun add any-base
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2017-10-09 |
| First published | 2015-05-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/any-base) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 30 |
| Author | Kamil Harasimowicz |
| Maintainers | mifczu |
| Keywords | number, convert, base, alphabet, short number, long numbers, dec, hex, bin, oct, any |

## Links

- npm: https://www.npmjs.com/package/any-base
- Repository: https://github.com/HarasimowiczKamil/any-base
- Homepage: https://github.com/HarasimowiczKamil/any-base#readme
- Issues: https://github.com/HarasimowiczKamil/any-base/issues
- npm.io page: https://npm.io/package/any-base

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2017-10-09
- 1.0.1 — 2016-11-30
- 1.0.0 — 2015-05-28

## README

# README #

The library allows you to convert any large numbers in any number base to another number base. The base is determined by specifying the alphabet. So is full freedom

[![NPM](https://nodei.co/npm/any-base.png?downloads=true&stars=true)](https://nodei.co/npm/any-base/)

## Installation ##

```
npm install any-base --save
```

## API ##

### AnyBase() ###

```
converterFunction = anyBase(sourceAlphabet, destinationAlphabet);
```

#### Parameters ####

* {String} __sourceAlphabet__      digits from smallest to the largest
* {String} __destinationAlphabet__ digits from smallest to the largest

#### Return Values ####

Returns __function__ that converts the number of source base to the destination

### Convert() ###

```
converterFunction(number)
```

#### Parameters ####

* {String} __number__ number of source base

#### Return Values ####

Returns number of destonation base

## Example ##

```js
var anyBase = require('any-base'),
dec2hex = anyBase(anyBase.DEC, anyBase.HEX),
shortId = anyBase(anyBase.DEC, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-+!@#$^'),
longId  = anyBase('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-+!@#$^', anyBase.DEC);

dec2hex('123456'); // return: '1E240'
shortId('1234567890'); // return: 'PtmIa'
longId('PtmIa'); // return: '1234567890'
```

---
_Source: https://npm.io/package/any-base · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
