Skip to content

Easily turn large values into their corresponding number and letter value - 1,300,000 -> 1.3m

License

Notifications You must be signed in to change notification settings

jxshco/small-number

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

small-number

travis npm version npm downloads Standard - JavaScript Style Guide

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

Install

Add small-number to your project using npm or yarn.

Install (NPM):

$ npm install small-number --save

Install (Yarn):

$ yarn add small-number

Usage

Import SmallNumber into Your Project

import SmallNumber from 'small-number'

Use Small Number

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

About

Easily turn large values into their corresponding number and letter value - 1,300,000 -> 1.3m

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published