UNPKG

react-native-graph-plus

Version:

📈 Beautiful, high-performance Graphs and Charts for React Native +

22 lines (18 loc) • 632 B
export function getSixDigitHex(color) { if (!color.startsWith('#')) throw new Error(`react-native-graph: "${color}" is not a valid hex color!`); const hexColor = color.substring(1); // removes '#' switch (hexColor.length) { case 3: { const sixDigitHex = hexColor.split('').map(hex => hex + hex).join(''); return `#${sixDigitHex}`; } case 6: return `#${hexColor}`; case 8: return `#${hexColor.substring(0, 6)}`; default: throw new Error(`react-native-graph: Cannot convert "${color}" to a six-digit hex color!`); } } //# sourceMappingURL=getSixDigitHex.js.map