UNPKG

@bothub-chat/ui

Version:

Bothub UI Components

2 lines (1 loc) 453 B
const e=e=>{if(!/#[\d, a-fA-F]{8}|#[\d, a-fA-F]{6}|#[\d, a-fA-F]{3}/.test(e))throw new Error("Invalid HEX. Source: hexToRgb function");let r;if(r=4===e.length?/#([\d, a-fA-F])([\d, a-fA-F])([\d, a-fA-F])/.exec(e):/#([\d, a-fA-F]{2})([\d, a-fA-F]{2})([\d, a-fA-F]{2})/.exec(e),null===r)throw new Error("No execValue. Source: hexToRgb function");const[n,o,t]=r.slice(1).map(e=>Number.parseInt(1===e.length?e+e:e,16));return[n,o,t]};export{e as hexToRgb};