percent-change
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
$ npm install --save percent-change
Tests
$ npm test
API
change(from, to, places, fmt)
Example
var change = var out = console// => '40.00%' out = console// => 0.4
To specify the decimal places:
var out = console// => '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
var change = var out = changeconsole// => '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