mwittig / node-milight-promise

A node module to control Milight LED bulbs and OEM equivalents such as Rocket LED, Limitless LED Applamp, Easybulb, s`luce, iLight, iBulb, and Kreuzer
MIT License
114 stars 27 forks source link

added hexToRgb function #29

Closed unm4sk1g closed 6 years ago

unm4sk1g commented 6 years ago

Takes the 6-digit hex code for colors (eg. #FFFFFF). Might be useful to someone, I didn't see it in the library, if it exists ignore this pull request, otherwise, could be a nice addition to the current converting functions.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-0.3%) to 97.6% when pulling 3719ecb97d8e066f42bbf8be38843f106ae08d92 on msunjic98:master into 12777c679f8cfe24e544a158620e9a10af221914 on mwittig:master.

unm4sk1g commented 6 years ago

Also, credits to Tim Down from StackOverflow for the function.

mwittig commented 6 years ago

Thanks for the PR. I'll look into that soon. Alternative would be to use a package tinyColor2 which provides a lightweight a general approach to color code conversion. Personally, I'd prefer that rather than adding helpers which are not used by the package itself.

mwittig commented 6 years ago

Also, credits to Tim Down from StackOverflow for the function.

For reference: https://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb

unm4sk1g commented 6 years ago

Even though tinyColor2 is very useful for this kind of stuff, since we have lots of conversion people already use by helper.js, this one shouldn't be a big of a deal, don't know why @coveralls hates me :joy:

mwittig commented 6 years ago

@msunjic98 wrote

Even though tinyColor2 is very useful for this kind of stuff, since we have lots of conversion people already use by helper.js, this one shouldn't be a big of a deal ...

Ok, fair enough.

don't know why @coveralls hates me

That is, because you did not write unit tests for the new function. Coverage is measured on execution of all unit tests.

unm4sk1g commented 6 years ago

Forgot about this. Added unit test for the new function.

mwittig commented 6 years ago

Thanks! Much appreciated