UNPKG

clcn

Version:

A lightweight CLI coloring utility with support for ANSI, HEX, gradients, rainbow, and dual ESM/CJS support.

15 lines (14 loc) 281 B
function hexToRgb(hex) { hex = hex.replace("#", ""); if (hex.length === 3) hex = hex.split("").map((c) => c + c).join(""); const bigint = parseInt(hex, 16); return { r: bigint >> 16 & 255, g: bigint >> 8 & 255, b: bigint & 255 }; } export { hexToRgb };