param value param decimalPlaces const roundWithDecimals = ( value ? , decimalPlaces = 2 ) => { if ( value === undefined ) { return ; } if ( typeof value !== 'number' || typeof decimalPlaces !== 'number' ) { throw new Error ( `Invalid parameters, both value "${ value }" (${ typeof value }) and decimalPlaces "${ decimalPlaces }" (${ typeof decimalPlaces }) must be of type number` ) ; } const factorOfTen = Math . pow ( 10 , decimalPlaces ) ; return Math . round ( value * factorOfTen ) / factorOfTen ; } ; export default roundWithDecimals ;