MCPcopy Index your code
hub / github.com/darkreader/darkreader / toFixed

Function toFixed

src/utils/color.ts:110–126  ·  view source on GitHub ↗
(n: number, digits = 0)

Source from the content-addressed store, hash-verified

108}
109
110function 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
128export function rgbToString(rgb: RGBA): string {
129 const {r, g, b, a} = rgb;

Callers 2

rgbToStringFunction · 0.85
hslToStringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected