markusn / color-diff

Implemets the CIEDE2000 color difference algorithm, conversion between RGB and lab color and mapping all colors in palette X to the closest color in palette Y based on the CIEDE2000 difference.
Other
359 stars 30 forks source link

Guard against external libraries modifying Array.prototype #7

Closed Munter closed 9 years ago

Munter commented 9 years ago

When running color-diff in an environment where Array.prototype has been amended with helper functions, the palette will some times return color objects with NaN in every dimension.

I tried using a for(var idx1; idx1 < a.length; idx1 += 1) loop, which would be cleaner, but when I do the tests are failing.

markusn commented 9 years ago

Hi Munter! Thanks for contributing to color-diff!

I'd prefer the solution using the modified loop, it should work if you change the loop to: for (var idx1 = 0; idx1 < a.length; idx1++) (the code you pasted missed the initialization of the index).

coveralls commented 9 years ago

Coverage Status

Coverage decreased (-1.44%) to 97.81% when pulling 6aec030493b64a9321da3a068a8228344cc230a5 on Munter:hasOwnProperty-fix into 8c74b04b75206e7aa2fd1dde7b79c4a339c05855 on markusn:master.

coveralls commented 9 years ago

Coverage Status

Coverage decreased (-1.44%) to 97.81% when pulling 6aec030493b64a9321da3a068a8228344cc230a5 on Munter:hasOwnProperty-fix into 8c74b04b75206e7aa2fd1dde7b79c4a339c05855 on markusn:master.

Munter commented 9 years ago

Right, I guess I was a bit tired when I tried that version. I've switched to a traditional for-loop now and the tests are passing. I've also verified that this version doesn't experience the original problem I encountered

coveralls commented 9 years ago

Coverage Status

Coverage decreased (-1.44%) to 97.81% when pulling e0a7c2e6f83519e0965104b56c7c1a2518686ac7 on Munter:hasOwnProperty-fix into 8c74b04b75206e7aa2fd1dde7b79c4a339c05855 on markusn:master.

coveralls commented 9 years ago

Coverage Status

Coverage decreased (-1.44%) to 97.81% when pulling e0a7c2e6f83519e0965104b56c7c1a2518686ac7 on Munter:hasOwnProperty-fix into 8c74b04b75206e7aa2fd1dde7b79c4a339c05855 on markusn:master.

Munter commented 9 years ago

And now with the hasOwnProperty check removed :)

coveralls commented 9 years ago

Coverage Status

Coverage remained the same at 99.25% when pulling 467627eb8b45ef698a3f9322ea590d0ccf3b7925 on Munter:hasOwnProperty-fix into 8c74b04b75206e7aa2fd1dde7b79c4a339c05855 on markusn:master.

markusn commented 9 years ago

Thanks for the contribution! I will publish a new version in npm during the weekend.

Munter commented 9 years ago

Thanks :+1:

markusn commented 9 years ago

Tagged as 0.1.7 and published in npm.

Munter commented 9 years ago

Ping @sunesimonsen

sunesimonsen commented 9 years ago

Great, thanks for the quick merge.