UNPKG

color-classifier

Version:

Classify the color along the reference color. using algorithm the CIEDE2000, RGB, HSV.

12 lines (9 loc) 234 B
export default function minBy(array, key) { const sortedArray = [...array]; sortedArray.sort((a, b) => { if (a[key] < b[key]) return -1; if (a[key] > b[key]) return 1; return 0; }); return sortedArray.shift(); }