# number-compressor

> An npm package used to compress and decompress numbers for better rendering

Latest version **2.0.2** (published 2023-01-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install number-compressor
pnpm add number-compressor
yarn add number-compressor
bun add number-compressor
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2023-01-16 |
| First published | 2021-11-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 (+25 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Wizi |
| Maintainers | wizi_ |
| Keywords | number, compressor |

## Links

- npm: https://www.npmjs.com/package/number-compressor
- Repository: https://github.com/Wizi8914/number-compressor
- Homepage: https://github.com/Wizi8914/number-compressor#readme
- Issues: https://github.com/Wizi8914/number-compressor/issues
- npm.io page: https://npm.io/package/number-compressor

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^0.20.0

## 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

- 2.0.2 (latest) — 2023-01-16
- 2.0.1 — 2023-01-16
- 1.2.6 — 2022-05-12
- 1.2.5 — 2022-02-21
- 1.2.4 — 2021-11-14
- 1.1.3 — 2021-11-06
- 1.1.2 — 2021-11-06
- 1.0.2 — 2021-11-06
- 1.0.1 — 2021-11-06
- 1.0.0 — 2021-11-06

## README

<h1 align="center">Number-Compressor ✨</h1>
<p align="center">
  <a href="https://nodei.co/npm/number-compressor/"><img src="https://nodei.co/npm/number-compressor.png?downloads=true&downloadRank=true&stars=true"></a>
</p>

## What is Number-Compressor ?
- An npm package used to compress and decompress numbers for better rendering

## Install the package 📥
```sh
npm install number-compressor
```

## Usage 📚
#### Compress function:
```js
const { compress } = require("number-compressor");

compress(100);
// => return 100

compress(1000);
// => return 1K

compress(1000000);
// => return 1M

compress(1000000000);
// => return 1B

compress(1000000000000);
// => return 1T

compress('test');
// => return Error message
```
#### You can set the number of decimal

```js
compress(274287, 3)
// => return 274.287K

compress(274287, 0)
// => return 274K
```
#### Uncompress function:
```js
const { uncompress } = require("number-compressor");

uncompress(10000);
// => return 10000

uncompress("1K");
// => return 1000

uncompress("1M");
// => return 1000000

uncompress("1B");
// => return 1000000000

uncompress("1T");
// => return 1000000000000

uncompress("1TT");
// => return Error message

uncompress("T");
// => return Error message
```
#### Define your own units
```js

const { compress, uncompress, setCustomUnit } = require("number-compressor");

//You can define units of up to two characters
const myUnits = ["P", "MP", "KO", "D"]

setCustomUnit(myUnits)

compress(1000)
// => return 1P

compress(1000000)
// => return 1MP

compress(2243192, 3)
// => return 2.243MP


uncompress("1ko")
// => return 1000000000

uncompress("1D")
// => return 1000000000000
```


## Developers 👨‍💻
- **[WIZI](https://github.com/Wizi8914)**

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