| 106 | // ================ |
| 107 | |
| 108 | const hexPairs = color => { |
| 109 | const split = color.split(""); |
| 110 | const pairs = color.length < 5 |
| 111 | ? split.map(string => string + string) |
| 112 | : split.reduce((array, string, index) => { |
| 113 | if (index % 2) |
| 114 | array.push(split[index - 1] + string); |
| 115 | return array; |
| 116 | }, []); |
| 117 | if (pairs.length < 4) |
| 118 | pairs.push("ff"); |
| 119 | return pairs; |
| 120 | }; |
| 121 | |
| 122 | const convert = color => |
| 123 | hexPairs(color).map(string => parseInt(string, 16)); |