figspec

Unofficial static Figma frame/file viewer available as HTML CustomElement

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
export function roundTo(x: number, to: number = 0) {
  if (to === 0) {
    return Math.round(x);
  }

  const p = Math.pow(10, to);

  return Math.round(x * p) / p;
}