UNPKG

chalk-pipe

Version:

Create chalk style schemes with simpler style strings

12 lines (11 loc) 354 B
export const normalizeHexColor = (text) => { let color = text.replace('#', ''); if (color.length < 6) { // eslint-disable-next-line unicorn/no-useless-spread color = [...color.slice(0, 3)].map((x) => x.repeat(2)).join(''); } else if (color.length > 6) { color = color.slice(0, 6); } return '#' + color; };