MCPcopy Index your code
hub / github.com/diffgram/diffgram / parseHex

Function parseHex

frontend/src/utils/colorUtils.js:258–278  ·  view source on GitHub ↗
(hex)

Source from the content-addressed store, hash-verified

256}
257
258function parseHex(hex) {
259 if (hex.startsWith('#')) {
260 hex = hex.slice(1);
261 }
262
263 hex = hex.replace(/([^0-9a-f])/gi, 'F');
264
265 if (hex.length === 3 || hex.length === 4) {
266 hex = hex.split('').map(function (x) {
267 return x + x;
268 }).join('');
269 }
270
271 if (hex.length === 6) {
272 hex = (0, padEnd)(hex, 8, 'F');
273 } else {
274 hex = (0, padEnd)((0, padEnd)(hex, 6), 8, 'F');
275 }
276
277 return "#".concat(hex).toUpperCase().substr(0, 9);
278}
279
280function parseGradient(gradient, colors, currentTheme) {
281 return gradient.replace(/([a-z]+(\s[a-z]+-[1-5])?)(?=$|,)/gi, function (x) {

Callers 1

parseGradientFunction · 0.85

Calls 2

replaceMethod · 0.80
splitMethod · 0.80

Tested by

no test coverage detected