Skip to content

huukhuong/react-format-number-shorten

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Format number

Installation

npm i react-format-number-shorten

Usage

Import package

import formatNumber from 'react-format-number-shorten';

Basic usage

const pi = 3.14159265359;

console.log(formatNumber(pi)); // 3
console.log(formatNumber(pi, { fixed: 2 })); // 3.14

const price = 125000;
console.log(formatNumber(price)); // 125,000
console.log(formatNumber(price, { decimalSeparator: '.' })); // 125.000

Format with shorten

const money = 1000000;

console.log(formatNumber(money, { shorten: true })); // 1M
console.log(formatNumber(money, { fixed: 2, shorten: true })); // 1.00M
console.log(formatNumber(money, { fixed: 2, shorten: true,  decimalSeparator: ',' })); // 1,00M

About

npm package for React, React Native to format a number to string beautify output

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published