mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-14 19:13:08 +02:00
10 lines
330 B
TypeScript
10 lines
330 B
TypeScript
|
export function extractAvgColorFromBlurhash(hash: string) {
|
||
|
return typeof hash == 'string'
|
||
|
? '#' + [...hash.slice(2, 6)]
|
||
|
.map(x => '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~'.indexOf(x))
|
||
|
.reduce((a, c) => a * 83 + c, 0)
|
||
|
.toString(16)
|
||
|
.padStart(6, '0')
|
||
|
: undefined;
|
||
|
}
|