# percent-change

> Calculate the change in percentage for two numbers

Latest version **1.0.1** (published 2015-11-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install percent-change
pnpm add percent-change
yarn add percent-change
bun add percent-change
```

Provides the command `percent-change`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2015-11-04 |
| First published | 2014-07-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Evan Lucas |
| Maintainers | evanlucas |
| Keywords | percent, percentage, change |

## Links

- npm: https://www.npmjs.com/package/percent-change
- Repository: https://github.com/evanlucas/percent-change
- Issues: https://github.com/evanlucas/percent-change/issues
- npm.io page: https://npm.io/package/percent-change

## Dependencies (2)

- [help](https://npm.io/package/help.md) ~2.0.0
- [nopt](https://npm.io/package/nopt.md) ~3.0.1

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2015-11-04
- 1.0.0 — 2015-11-04
- 0.1.2 — 2015-05-11
- 0.1.0 — 2014-07-07
- 0.0.1 — 2014-07-07

## README

# percent-change

[![Build Status](https://travis-ci.org/evanlucas/percent-change.svg)](https://travis-ci.org/evanlucas/percent-change)
[![codecov.io](https://codecov.io/github/evanlucas/percent-change/coverage.svg?branch=master)](https://codecov.io/github/evanlucas/percent-change?branch=master)

*Note: `percent-change` is only supported on iojs and node v4+.
To use with an older version of node, please use `percent-change@0.1`.*

## Installation

```bash
$ npm install --save percent-change
```

## Tests

```bash
$ npm test
```

## API

### change(from, to, places, fmt)

#### Example

```js
var change = require('percent-change')
var out = change(5, 7, true)
console.log(out)
// => '40.00%'

out = change(5, 7, false)
console.log(out)
// => 0.4
```

To specify the decimal places:

```js
var out = change(5, 7, 0, true)
console.log(out)
// => '40%'
```

#### Params

- from {Number} The _from_ number
- to {Number} The _to_ number
- places {Number} The number of decimal places (optional, defaults to 2)
- fmt {Boolean} Should we format as a percentage? (defaults to false)

### change.format(from, to, places)

#### Example

```js
var change = require('percent-change')
var out = change.format(5, 7)
console.log(out)
// => '40.00%'
```

#### Params

- from {Number} The _from_ number
- to {Number} The _to_ number
- places {Number} The number of decimal places (optional, defaults to 2)

## License

Licensed under the MIT license. For more info, see `LICENSE`

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