https://github.com/jxshco/small-number
Easily turn large values into their corresponding number and letter value - 1,300,000 -> 1.3m
https://github.com/jxshco/small-number
es6 javascript millions number numbers-to-text small thousands
Last synced: 4 months ago
JSON representation
Easily turn large values into their corresponding number and letter value - 1,300,000 -> 1.3m
- Host: GitHub
- URL: https://github.com/jxshco/small-number
- Owner: jxshco
- License: mit
- Created: 2018-01-24T14:41:56.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-10-08T19:48:48.000Z (over 6 years ago)
- Last Synced: 2025-08-09T16:28:35.904Z (10 months ago)
- Topics: es6, javascript, millions, number, numbers-to-text, small, thousands
- Language: JavaScript
- Size: 63.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
small-number
Easily turn large values into their corresponding number and letter value - 1,300,000 -> 1.3m
## Why?
While working on freelance/agency work I would tend to come across situations where this was needed. I re-wrote this script each and every time I had a project that needed it, each being different, better and worse.
## Table of Contents
- Quick start
- [Install](#install)
- [Usage](#usage)
- [Contributing](#contributing)
- [Licence](#usage)
## Install
Add small-number to your project using npm or yarn.
Install (NPM):
```bash
$ npm install small-number --save
```
Install (Yarn):
```bash
$ yarn add small-number
```
## Usage
Import SmallNumber into Your Project
```js
import SmallNumber from 'small-number'
```
Use Small Number
```js
smallNumber(123456)
// 123.5k
smallNumber(123456, 0)
// 124k
smallNumber(123456, 2)
// 123.46k
let messages = 9831324
let message = `You have ${smallNumber(messages)} unread emails`
//You have 9.8m unread emails
```
## Contributing
Pull requests for new features, bug fixes, and suggestions are welcome!
## License
[MIT](https://github.com/jxshco/small-number/blob/master/LICENSE)