UNPKG

@visulima/colorize

Version:

Terminal and Console string styling done right.

16 lines (14 loc) 605 B
var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); const convertHexToRgb = /* @__PURE__ */ __name((hex) => { let [, color] = /([a-f\d]{3,6})/i.exec(hex) ?? []; const length_ = color ? color.length : 0; if (length_ === 3) { color = color[0] + color[0] + color[1] + color[1] + color[2] + color[2]; } else if (length_ !== 6) { return [0, 0, 0]; } const number_ = Number.parseInt(color, 16); return [number_ >> 16 & 255, number_ >> 8 & 255, number_ & 255]; }, "convertHexToRgb"); export { convertHexToRgb };