Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
channel => {
// detect channel
const isHue = channel === 'hue';
const isRGB = !isHue && blueGreenRedMatch.test(channel);
// normalized value of the channel
const value = normalize(channels[channel], channel);
// assign channel to new object
color[channel] = value;
if (isRGB) {
// conditionally preserve the hue
color.hue = rgb2hue(color.red, color.green, color.blue, base.hue || 0);
}
}
);
constructor(color) {
this.color = Object(Object(color).color || color);
this.color.colorspace = this.color.colorspace
? this.color.colorspace
: 'red' in color && 'green' in color && 'blue' in color
? 'rgb'
: 'hue' in color && 'saturation' in color && 'lightness' in color
? 'hsl'
: 'hue' in color && 'whiteness' in color && 'blackness' in color
? 'hwb'
: 'unknown';
if (color.colorspace === 'rgb') {
this.color.hue = rgb2hue(color.red, color.green, color.blue, color.hue || 0);
}
}