# kmformatter

> Convert numbers to k,m... made easy

Latest version **0.0.3** (published 2023-05-05) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install kmformatter
pnpm add kmformatter
yarn add kmformatter
bun add kmformatter
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2023-05-05 |
| First published | 2023-05-05 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 37.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Khaing Myel Khant |
| Maintainers | khaingmyel |
| Keywords | formatter, k, kformatter, text, formatting |

## Links

- npm: https://www.npmjs.com/package/kmformatter
- Repository: https://github.com/kmkhant/kformatter
- Homepage: https://github.com/kmkhant/kformatter#readme
- Issues: https://github.com/kmkhant/kformatter/issues
- npm.io page: https://npm.io/package/kmformatter

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 0.0.3 (latest) — 2023-05-05
- 0.0.2 — 2023-05-05
- 0.0.1 — 2023-05-05

## README

# kformatter

Convert numbers to k,m... made easy

Solution to express numbers in **k,M,G,T,P,E**
e.g 1234 to 1.2k, 1243215 to 1.2M

## Installation

Using npm:

`  $ npm i kmformatter`

## Quick Start

Import the libary and use the format nFormatter(number, decimal)

```js
// load the library
import { formatter } from 'kmformatter';

console.log(formatter(1234, 1));
console.log(formatter(1234, 2));

console.log(formatter(3423567, 1));
console.log(formatter(3423567, 3));
```

output

```console
$ 1.2k
$ 1.23k
$ 3.4M
$ 3.423M
```

Special thanks to [@Salman A](https://stackoverflow.com/users/87015/salman-a). He wrote the entire solution, I just modified and released it as an npm package for easier usage.

[This is](https://stackoverflow.com/questions/9461621/format-a-number-as-2-5k-if-a-thousand-or-more-otherwise-900) the original reddit comment I took the code from.

---
_Source: https://npm.io/package/kmformatter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
