Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rodrigobdz/percentage-diff

Calculate percentage difference between two numbers
https://github.com/rodrigobdz/percentage-diff

decrease delta increase math-calculator npm-module numbers-comparison percentage-calculator percentage-change yarn

Last synced: about 1 month ago
JSON representation

Calculate percentage difference between two numbers

Awesome Lists containing this project

README

        

# percentage-diff [![Build Status](https://travis-ci.com/rodrigobdz/percentage-diff.svg?branch=master)](https://travis-ci.com/rodrigobdz/percentage-diff) [![codecov](https://codecov.io/gh/rodrigobdz/percentage-diff/badge.svg?branch=master)](https://codecov.io/gh/rodrigobdz/percentage-diff?branch=master)

> Calculate percentage difference between two numbers

## Install

```sh
$ npm install percentage-diff
```

## Usage

```js
const percentageDiff = require('percentage-diff');

percentageDiff(50, 75);
//=> 50
percentageDiff.toPercentage(50);
//=> 50%
percentageDiff(45,35);
//=> -22.22
```

## API

### percentageDiff(firstNr, secondNr)

#### firstNr

Type: `number`

#### secondNr

Type: `number`

### percentageDiff.toPercentage(value)

#### value

Type: `number`

## Credits

* [generator-lnm](https://github.com/rodrigobdz/generator-lnm) - Awesome node module generator

## License

[MIT](license) © [Rodrigo Bermudez Schettino](https://rodrigobdz.github.io)