Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-abbreviation-number

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-abbreviation-number

Abbreviate numbers in javascript

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
increased by18.19%
Maintainers
1
Weekly downloads
 
Created
Source

js-abbreviation-number

Abbreviate numbers in javascript

CI/CD GitHub license PRs Welcome codecov CodeFactor NPM GitHub contributors


Installation

npm install js-abbreviation-number

Usage

import { abbreviateNumber } from "js-abbreviation-number";

const num = abbreviateNumber(1000, 1); // expected 1.0K

const num = abbreviateNumber(12, 0); // expected 12

const num = abbreviateNumber(1100, 2); // expected 1.10K

const num = abbreviateNumber(1100, 2, {padding: false}); // expected 1.1K

const num = abbreviateNumber(1234.56, 2); // expected 1.23K

const num = abbreviateNumber(1234, 1, {symbols: ['', 'kg']}); // expected 1.2kg

const num = abbreviateNumber(1234567, 1, {symbols: ['', 'kg']}); // expected 1234.5kg

abbreviateNumber(num: number, digit?: number, options?: {symbols?: string[]; padding: boolean}): string

digit is optional (unless you need to specify the options object). It defaults to 1.

The options object is optional too:

  • symbols can be an array of units, defaulting to ["", "K", "M", "G", "T", "P", "E"].
  • padding determines whether to keep the exact number of digits or to drop trailing zeroes.

Contributing

Thank you for your interest in contributing! Please feel free to put up a PR for any issue or feature request.

Give me a Star

If you think this project is helpful just give me a ⭐️ Star is enough because i don't drink coffee 😃

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Author

Made with ❤️ by Mohsen Madani.

Keywords

FAQs

Package last updated on 06 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc