convert-to-compact
TypeScript icon, indicating that this package has built-in type declarations

1.1.121 • Public • Published

convert-to-compact

convert-to-compact is a utility package that converts large numbers into a more readable format using abbreviations like K (for thousands), M (for millions), and B (for billions).

This package is perfect for simplifying large numbers in user interfaces, reports, or analytics, making them more digestible.

Installation

You can install convert-to-compact via NPM:

npm install convert-to-compact

Usage TypeScript

import { convertToKMB } from 'convert-to-compact';

const result1 = convertToKMB(224000);
console.log(result1); // Output: '224K'

const result2 = convertToKMB(1500000);
console.log(result2); // Output: '1.5M'

const result3 = convertToKMB(5000000000);
console.log(result3); // Output: '5B'

Usage JavaScript

const {convertToKMB} = require("convert-to-compact");

const result1 = convertToKMB(224000);
console.log(result1); // Output: '224K'

const result2 = convertToKMB(1500000);
console.log(result2); // Output: '1.5M'

const result3 = convertToKMB(5000000000);
console.log(result3); // Output: '5B'

Package Sidebar

Install

npm i convert-to-compact

Weekly Downloads

170

Version

1.1.121

License

MIT

Unpacked Size

4.45 kB

Total Files

7

Last publish

Collaborators

  • phrittech