in newswires/client/src/colour-utils.ts [2:22]
function parseColor(color = '') {
if (typeof color !== 'string') {
throw new TypeError('Color should be string!');
}
const hexMatch = /^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i.exec(color);
if (hexMatch) {
return hexMatch.splice(1).map((c) => Number.parseInt(c, 16));
}
const hexMatchShort = /^#?([\da-f])([\da-f])([\da-f])$/i.exec(color);
if (hexMatchShort) {
return hexMatchShort.splice(1).map((c) => Number.parseInt(c + c, 16));
}
if (color.includes(',')) {
return color.split(',').map((p) => Number.parseInt(p));
}
throw new Error('Invalid color format! Use #ABC or #AABBCC or r,g,b');
}