UNPKG

chalk-pipe

Version:

Create chalk style schemes with simpler style strings

11 lines (10 loc) 292 B
export const normalizeHexColor = (text) => { let color = text.replace('#', ''); if (color.length < 6) { color = [...color.slice(0, 3)].map((x) => x.repeat(2)).join(''); } else if (color.length > 6) { color = color.slice(0, 6); } return '#' + color; };