gka / chroma.js

JavaScript library for all kinds of color manipulations
https://gka.github.io/chroma.js/
Other
10.08k stars 543 forks source link

Idempotency failure cannot use chroma to return a same value.... #276

Open Luxcium opened 3 years ago

Luxcium commented 3 years ago

When I am trying to test my application and I try to pass some value... I can't not get expected value: « chroma('FFBBCCDD').hex('rgba') -> #ffbbccde » or even with « chroma('#ff055088').hex() === '#ff055088' false #ff055087 »

console.log(
  "chroma('#ffa500bb').hex('rgba') === '#ffa500bb'",
  chroma('#ffa500bb').hex('rgba') === '#ffa500bb',
  chroma('#ffa500bb').hex('rgba')
);
// chroma('#ffa500bb').alpha(0.75).hex('rgba') === '#ffa500bb' false #ffa500ba

Screenshot_20210803_195611

❯ ts-node "[...]/pop-n-lock-theme-vscode/helpers/tools/functions/chroma-test.ts"
chroma('FFBBCCDD').hex('rgba') -> #ffbbccde
chroma('orange').hex() === '#ffa500' true
chroma('orange').alpha(0.75).hex() === '#ffa500bf' true #ffa500bf
chroma('#ff055088').hex('rgba') === '#ff055088' false #ff055087
console.log(
  "chroma('FFBBCCDD').hex('rgba') ->",
  chroma('FFBBCCDD').hex('rgba')
);
// chroma('FFBBCCDD').hex('rgba') -> #ffbbccde

Screenshot_20210803_193519

Luxcium commented 3 years ago

I am unable to pass my own tests ... I changed the value to reflect the erroneous result then I changed my code and ended up getting the expected result but the test failed because I imputed the other value (the erroneous one)

Screenshot_20210803_193024

Luxcium commented 3 years ago

I would have the same expectation for the short version:

console.log(
  "chroma('#f058').hex() === '#ff005588'",
  chroma('#f058').hex() === '#ff005588',
  chroma('#f058').hex()
  // chroma('#f058').hex() === '#f058' false #ff005587
);

Screenshot_20210803_202630