Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function (hexcolor) {
hexcolor = stringToHex(hexcolor)
const rgbColor = hexToRGB(hexcolor)
const cieLabColor = rgbToCIELab(rgbColor)
const matchedColor = []
colors.forEach(element => {
const hexValue = stringToHex(element.hex)
const rgbValue = hexToRGB(hexValue)
const cieLabValue = rgbToCIELab(rgbValue)
element.cieLab = cieLabValue
if (matchColor(cieLabColor, element).status > 0) {
matchedColor.push(matchColor(cieLabColor, element))
}
})
const matched = matchedColor.reduce((prevColor, currentColor) => (prevColor.delta < currentColor.delta) ? prevColor : currentColor)
return matched
}