percentage-change
v3.0.3
Published
Binary operator of percentage-change
Downloads
21
Maintainers
Readme
percentage-change
Binary operator of percentage-change
Install
npm install percentage-change
Use
▸ percentageChange(start
: number, end
: number): Option‹number›
Binary operator of percentage-change
Parameters:
| Name | Type |
| ------- | ------ |
| start
| number |
| end
| number |
Returns: Option‹number›
import { percentageChange } from "percentage-change";
import { some, none } from "fp-ts/Option";
/* Standard use */
percentageChange(100, 200);
//=>some(100)
percentageChange(100, 75);
//=>some(-25)
/* Special cases */
percentageChange(0, 0);
//=>some(0)
percentageChange(0, 100);
//=>some(Infinity)
percentageChange(100, 0);
//=>some(-100)
percentageChange(NaN, 0);
//=>none
percentageChange(0, NaN);
//=>none
percentageChange(Infinity, 0); // -Infinity works the same way
//=>none
percentageChange(0, Infinity); // -Infinity works the same way
//=>none
Option type compliant with the fantasy-land specification.