adjustByPercentage
functionChanges a value by a percentage: a positive percentage increases it, and a negative one decreases it, to 0 at most. A value of 0 stays 0.
adjustByPercentage<T extends Partial<IConfig>>(
value: Value,
percentage: Value,
config?: T,
): IOutput<T>Parameters
valueValueThe value to change.
percentageValueThe percentage to change it by.
config?THow the result is processed.
Returns
IOutput<T>The changed value.
Throws
INVALID_VALUEif any of the given values isn't a finite number or BigNumber throws an errorINVALID_DECIMAL_PLACESif the number of decimal places is invalid for any reasonINVALID_ROUNDING_MODEif the rounding mode name is not supportedINVALID_TYPEif the processing type is not supportedNEGATIVE_VALUE_NOT_ALLOWEDif the value is negative
import { adjustByPercentage } from 'jg-bignumber';
adjustByPercentage(100, 25); // => 125
adjustByPercentage(100, -10); // => 90