Open ianrios opened 2 years ago
We need a round function to mimic the lodash round function (allows optional fixed rounding decimal place precision)
example definition: _.round(n: number, p?: number)
_.round(n: number, p?: number)
This would be added to the numbers category in the docs.
lodash reference: https://lodash.com/docs/4.17.15#round
My current workaround, with JS Math.round, Math.pow, and radash toFloat:
Math.round
Math.pow
toFloat
const num = 123.456 const precision = 2 const mult = Math.pow(10, precision) const rounded = Math.round(num * mult) / mult const fixed = _.toFloat(rounded.toFixed(precision)) // => 123.46
My Ideal workflow using only radash round:
round
const num = 123.456 const precision = 2 const rounded = _.round(num, precision) // => 123.46
Hey @ianrios thanks for bringing this up 👏 I think round would be a great addition to radash. I think it's a pretty quick add as well.
@rayepps , Can i work on this
We need a round function to mimic the lodash round function (allows optional fixed rounding decimal place precision)
example definition:
_.round(n: number, p?: number)
This would be added to the numbers category in the docs.
lodash reference: https://lodash.com/docs/4.17.15#round
My current workaround, with JS
Math.round
,Math.pow
, and radashtoFloat
:My Ideal workflow using only radash
round
: