# pretty-currency

> format number or string to currency.

Latest version **0.1.6** (published 2019-03-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install pretty-currency
pnpm add pretty-currency
yarn add pretty-currency
bun add pretty-currency
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2019-03-23 |
| First published | 2019-03-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Venus |
| Maintainers | bbbbx |
| Keywords | format, number, string |

## Links

- npm: https://www.npmjs.com/package/pretty-currency
- Repository: https://github.com/bbbbx/pretty-currency
- Homepage: https://github.com/bbbbx/pretty-currency#readme
- Issues: https://github.com/bbbbx/pretty-currency/issues
- npm.io page: https://npm.io/package/pretty-currency

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 0.1.6 (latest) — 2019-03-23
- 0.1.5 — 2019-03-19
- 0.1.4 — 2019-03-18
- 0.1.3 — 2019-03-18
- 0.1.2 — 2019-03-18
- 0.1.1 — 2019-03-18
- 0.1.0 — 2019-03-18

## README

# Pretty currency

  Pretty your number or string to a readable currency:  `123456789` → `'123,456,789'`.

  [![NPM Version][npm-image]][npm-url]
  [![NPM Downloads][downloads-image]][downloads-url]
  [![Build Status][travis-image]][travis-url]

## Install

  ```bash
  npm install --save pretty-currency
  ```

## Usage

  ```js
  const prettyCurrency = require('pretty-currency')

  let num = 123456789
  num = prettyCurrency(num)
  console.log(num)  // '123,456,789'

  num = 123456.7899
  num = prettyCurrency(num)
  console.log(num)  // '123,456.7899'
  ```

  the parameter must be a number or string, if not, it will throw a TypeError, for example:

  ```js
  prettyCurrency({})     // Thrown: TypeError: parameter must be a number or string.
  prettyCurrency(false)  // Thrown: TypeError: parameter must be a number or string.
  ```

  if the parameter is string, it must start with number, for example:

  ```js
  prettyCurrency('1234.123forssa')  // '1,234.123'
  ```

  if not, it will throw an Error, for example:

  ```js
  prettyCurrency('ow1234.123qw')  // Thrown: Error: parameter is invalid.
  ```

## Contribution

  Any PR is welcome! This package use Babel to compile and Flow for static type check.

  Install dependencies:

  ```bash
  npm install
  ```

  after patching `index.js`, you can build it:

  ```bash
  npm run build
  ```

  then, run all test cases:

  ```bash
  npm run test
  ```

  Before you submit your awesome PRs, please passed all tests first.

  If you have any edge test case, please let me know. ;)

## License

  MIT

[npm-image]: https://img.shields.io/npm/v/pretty-currency.svg
[npm-url]: https://npmjs.org/package/pretty-currency
[downloads-image]: https://img.shields.io/npm/dm/pretty-currency.svg
[downloads-url]: https://npmjs.org/package/pretty-currency
[travis-image]: https://img.shields.io/travis/bbbbx/pretty-currency/master.svg
[travis-url]: https://www.travis-ci.org/bbbbx/pretty-currency

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