Skip to content

An open-source JavaScript library for formatting and manipulating numbers.

License

Notifications You must be signed in to change notification settings

Bunlong/numer.js

Repository files navigation

numer.js

Numer.js is an open-source JavaScript library for formatting and manipulating numbers.

NPM npm bundle size JavaScript Style Guide

🎁 Features

  • Numer() constructor
    • format() instance method

🔧 Install

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

If you don't want to use npm or yarn, numer.min.js can be downloaded to your project source.

📖 Documentation

Constructor

  • Numer(options)
    • Creates a new Numer object.
new Numer(options)

Parameters

  • options
    • An object with some or all of the following properties.

style

The formatting style to use.

  • comma for comma formatting.
  • abbreviation for abbreviation formatting.
  • ordinal for ordinal formatting.

Instance methods

  • Numer.prototype.format(number)
    • Getter function that formats a number according to the formatting options of this Numer object.
format(number)

Parameters

  • number
    • A Number or BigInt to format.

💡 Usage

🎀 format()

// Node.js
const Numer = require("numer.js");

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"

📜 Changelog

Latest version 0.1.0 (2021-09-07):

  • Numer() constructor
    • format() instance method

Details changes for each release are documented in the CHANGELOG.md.

❗ Issues

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.

💪 Contribution

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

🏆 Contributors

Bunlong
Bunlong

⚖️ License

The MIT License License: MIT

About

An open-source JavaScript library for formatting and manipulating numbers.

Topics

Resources

License

Stars

Watchers

Forks

Packages