Tiny Number Format JavaScript Library – numer.js

Category: Javascript , Recommended | September 13, 2021
Author:Bunlong
Views Total:34 views
Official Page:Go to website
Last Update:September 13, 2021
License:MIT

Preview:

Tiny Number Format JavaScript Library – numer.js

Description:

numer.js is a super tiny (1kb minified) JavaScript library for converting, formatting and manipulating numbers.

How to use it:

1. Install the numer.js with NPM.

# Yarn
$ yarn add numer.js

# NPM
$ npm i numer.js --save

2. Import the numer.js library.

<script src="numer.js"></script>

3. Format a number with commas as thousands separators.

new Numer({ 
    style: 'comma' 
}).format(1000000);
=> 1,000,000

4. Abbreviate large numbers.

new Numer({ 
    style: 'abbreviation' 
}).format(123456789);
=> 0.1B

5. Format a number as ordinal.

new Numer({ 
    style: 'ordinal' 
}).format(2);
=> 2nd

You Might Be Interested In:


Leave a Reply