xvmcmm/node_modules/culori/src/round.js
2024-06-04 13:41:33 +02:00

12 lines
283 B
JavaScript

// From: https://github.com/d3/d3-format/issues/32
const r = (value, precision) =>
Math.round(value * (precision = Math.pow(10, precision))) / precision;
const round =
(precision = 4) =>
value =>
typeof value === 'number' ? r(value, precision) : value;
export default round;