smartRound = (precision, data) => {
  for (
    let i = data.length,
      tolerance = +Math.pow(0.1, precision).toFixed(precision);
    i--;

  ) {
    if (toFixed(data[i], precision) !== data[i]) {
      const rounded = +data[i].toFixed(precision - 1);
      data[i] =
        +Math.abs(rounded - data[i]).toFixed(precision + 1) >= tolerance
          ? +data[i].toFixed(precision)
          : rounded;
    }
  }

  return data;
}
Decrease accuracy of floating-point numbers in transforms keeping a specified
number of decimals. Smart rounds values like 2.349 to 2.35.

@param {number} precision
@param {number[]} data
@returns {number[]}