Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wizi8914/number-compressor
An npm package used to compress and decompress numbers for better rendering
https://github.com/wizi8914/number-compressor
compression npm numbers package rendering
Last synced: 7 days ago
JSON representation
An npm package used to compress and decompress numbers for better rendering
- Host: GitHub
- URL: https://github.com/wizi8914/number-compressor
- Owner: Wizi8914
- License: mit
- Created: 2021-11-06T14:29:03.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-01-16T18:46:47.000Z (about 2 years ago)
- Last Synced: 2025-02-06T21:48:29.940Z (12 days ago)
- Topics: compression, npm, numbers, package, rendering
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/number-compressor
- Size: 14.6 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Number-Compressor ✨
## 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 100compress(1000);
// => return 1Kcompress(1000000);
// => return 1Mcompress(1000000000);
// => return 1Bcompress(1000000000000);
// => return 1Tcompress('test');
// => return Error message
```
#### You can set the number of decimal```js
compress(274287, 3)
// => return 274.287Kcompress(274287, 0)
// => return 274K
```
#### Uncompress function:
```js
const { uncompress } = require("number-compressor");uncompress(10000);
// => return 10000uncompress("1K");
// => return 1000uncompress("1M");
// => return 1000000uncompress("1B");
// => return 1000000000uncompress("1T");
// => return 1000000000000uncompress("1TT");
// => return Error messageuncompress("T");
// => return Error message
```
#### Define your own units
```jsconst { 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 1Pcompress(1000000)
// => return 1MPcompress(2243192, 3)
// => return 2.243MPuncompress("1ko")
// => return 1000000000uncompress("1D")
// => return 1000000000000
```## Developers 👨💻
- **[WIZI](https://github.com/Wizi8914)**