https://github.com/pqt/abbreviate
:abacus: Abbreviate numbers in the Thousands (K), Millions (M), Billions (B) and Trillions (T)
https://github.com/pqt/abbreviate
abbreviate-numbers billions npm-package number-abbreviation trillions typescript
Last synced: 2 months ago
JSON representation
:abacus: Abbreviate numbers in the Thousands (K), Millions (M), Billions (B) and Trillions (T)
- Host: GitHub
- URL: https://github.com/pqt/abbreviate
- Owner: pqt
- License: mit
- Created: 2020-03-13T06:26:21.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-17T18:49:29.000Z (about 5 years ago)
- Last Synced: 2023-09-19T23:53:27.732Z (over 1 year ago)
- Topics: abbreviate-numbers, billions, npm-package, number-abbreviation, trillions, typescript
- Language: TypeScript
- Homepage: https://npmjs.com/@pqt/abbreviate
- Size: 73.2 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
abbreviate
Abbreviate numbers in the Thousands (K), Millions (M), Billions (B) and Trillions (T)## Installation
```
npm install @pqt/abbreviate
# OR
yarn add @pqt/abbreviate
```## Usage
```js
import { abbreviate } from "@pqt/abbreviate";// Thousands
abbreviate(1234); // => 1K
abbreviate(1234, 1); // => 1.2K
abbreviate(1234, 2); // => 1.23K
abbreviate(1234, 3); // => 1.234K// Millions
abbreviate(1234123); // => 1M
abbreviate(1234123, 1); // => 1.2M
abbreviate(1234123, 2); // => 1.23M
abbreviate(1234123, 3); // => 1.234M// Billions
abbreviate(1234123412); // => 1B
abbreviate(1234123412, 1); // => 1.2B
abbreviate(1234123412, 2); // => 1.23B
abbreviate(1234123412, 3); // => 1.234B// Trillions
abbreviate(1234123412); // => 1T
abbreviate(1234123412, 1); // => 1.2T
abbreviate(1234123412, 2); // => 1.23T
abbreviate(1234123412, 3); // => 1.234T
```## License
MIT