Javascript library for calculating relative quantity changes, such as:
50 => 200 = 3 (+300%) (x4)
200 => 50 = -0.75 (-75%) (x0.25)
var initial_quantity = 50,
final_quantity = 200;
var relchange_instance = RelativeChange.Raw.calculate(initial_quantity, final_quantity);
var relchange = relchange_instance.val(); // 3
// Feeling like some convertions
var percentage_instance = relchange_instance.percentage();
var percentage = relchangepercentage_instance.val(); // 300 (+300%)
var multiplier_instance = relchange_instance.multiplier();
var multiplier = multiplier_instance.val(); // 4 (x4)
All constructors return instance of RelativeChange.Raw
calculate(/*Number */initial_quantity, /*Number */final_quantity)
fromRaw(/*Number */relchange)
fromPercentage(/*Number */percentage)
fromMultiplier(/*Number */multiplier)
val()
@returns instance ofNumber
percentage()
@returns instance ofRelativeChange.Percentage
multiplier()
@returns instance ofRelativeChange.Multiplier
All constructors return instance of RelativeChange.Percentage
calculate(/*Number */initial_quantity, /*Number */final_quantity)
fromRaw(/*Number */relchange)
fromPercentage(/*Number */percentage)
fromMultiplier(/*Number */multiplier)
val()
@returns instance ofNumber
raw()
@returns instance ofRelativeChange.Raw
multiplier()
@returns instance ofRelativeChange.Multiplier
All constructors return instance of RelativeChange.Multiplier
calculate(/*Number */initial_quantity, /*Number */final_quantity)
fromRaw(/*Number */relchange)
fromPercentage(/*Number */percentage)
fromMultiplier(/*Number */multiplier)
val()
@returns instance ofNumber
raw()
@returns instance ofRelativeChange.Raw
percentage()
@returns instance ofRelativeChange.Percentage