(n: number, digits = 0)
| 108 | } |
| 109 | |
| 110 | function toFixed(n: number, digits = 0): string { |
| 111 | const fixed = n.toFixed(digits); |
| 112 | if (digits === 0) { |
| 113 | return fixed; |
| 114 | } |
| 115 | const dot = fixed.indexOf('.'); |
| 116 | if (dot >= 0) { |
| 117 | const zerosMatch = fixed.match(/0+$/); |
| 118 | if (zerosMatch) { |
| 119 | if (zerosMatch.index === dot + 1) { |
| 120 | return fixed.substring(0, dot); |
| 121 | } |
| 122 | return fixed.substring(0, zerosMatch.index); |
| 123 | } |
| 124 | } |
| 125 | return fixed; |
| 126 | } |
| 127 | |
| 128 | export function rgbToString(rgb: RGBA): string { |
| 129 | const {r, g, b, a} = rgb; |
no outgoing calls
no test coverage detected