[web] Lint source code

This commit is contained in:
Alain Nussbaumer
2024-04-01 15:13:42 +02:00
parent 5640c33a67
commit be931f4173
4 changed files with 12 additions and 16 deletions

View File

@@ -1,15 +1,15 @@
const toColor = (string) => {
let hash = 0
for (let i = 0; i < string.length; i++) {
hash = string.charCodeAt(i) + ((hash << 5) - hash)
for (const char of string) {
hash = char.charCodeAt(0) + ((hash << 5) - hash)
}
return (hash & 0x00ffffff).toString(16)
}
const luminance = (color) =>
[0.2126, 0.7152, 0.0722].reduce(
(luminance, factor, index) =>
luminance + Number(`0x${color.slice(index * 2, index * 2 + 2)}`) * factor,
(value, factor, index) =>
value + Number(`0x${color.slice(index * 2, index * 2 + 2)}`) * factor,
0
) / 255