btw, the JS port is not perf-optimized (it's a straight compilation from haxe to js).
i hand-ported the C version [1] locally that avoids heap-allocating any objects or arrays, which makes it about 40% faster. i'm hoping it gets to replace the "official" js port at some point, but i still need to run it through all the tests [2]. if anyone is interested in helping out with this (i'm tight on time right now), i'll publish it.
initial benchmark of 100k random RGB triplets completes in 100ms in Chrome 80 and 60ms in Firefox 73, on a pretty average Core i5-7500T @ 2.70GHz. 1M triplets is 680ms in chrome and 421ms in firefox. the official JS port gets 934ms in Chrome and 545ms in Firefox for 1M triplets.
For reference, a typical jpeg image contains < 300k unique colors.
[1] https://github.com/hsluv/hsluv-c
[2] https://github.com/hsluv/hsluv-c/blob/master/tests/scripts/s...