Numer.js is an open-source JavaScript library for formatting and manipulating numbers.
- Numer() constructor
- format() instance method
numer.js is available on npm. It can be installed with the following command:
npm install numer.js --save
numer.js is available on yarn as well. It can be installed with the following command:
yarn add numer.js --save
- Numer(options)
- Creates a new Numer object.
new Numer(options)
- options
- An object with some or all of the following properties.
The formatting style to use.
- comma for comma formatting.
- abbreviation for abbreviation formatting.
- ordinal for ordinal formatting.
- Numer.prototype.format(number)
- Getter function that formats a number according to the formatting options of this Numer object.
format(number)
- number
- A Number or BigInt to format.
console.log(new Numer({ style: 'comma' }).format(1000000));
// expected output: "1,000,000"
console.log(new Numer({ style: 'abbreviation' }).format(9812730));
// expected output: 9.8M
console.log(new Numer({ style: 'ordinal' }).format(1));
// expected output: "1st"
If you think any of the numer.js
can be improved, please do open a PR with any updates and submit any issues. Also, I will continue to improve this, so you might want to watch/star this repository to revisit.
We'd love to have your helping hand on contributions to numer.js
by forking and sending a pull request!
Your contributions are heartily ♡ welcome, recognized and appreciated. (✿◠‿◠)
How to contribute:
- Open pull request with improvements
- Discuss ideas in issues
- Spread the word
- Reach out with any feedback
Bunlong |