contrastColor = (color) => {
  const [r, g, b] = removeAlpha(...color.match(/([0-9.]{1,3})/g).map(Number));
  const yiq = (r * 299 + g * 587 + b * 114) / 1000;

  return yiq >= 128 ? "rgb(0,0,0)" : "rgb(255,255,255)";
}
Determine contrasting color for a given color
Uses official W3C formula to make calculations
@param {string} color