@shardus/monitor-client
Advanced tools
Comparing version 2.5.0 to 2.5.1
{ | ||
"name": "@shardus/monitor-client", | ||
"version": "2.5.0", | ||
"version": "2.5.1", | ||
"description": "", | ||
@@ -24,2 +24,2 @@ "main": "entry.js", | ||
} | ||
} | ||
} |
@@ -25,15 +25,15 @@ const INTERVAL = 10_000 | ||
// From https://stackoverflow.com/questions/3426404/create-a-hexadecimal-colour-based-on-a-string-with-javascript | ||
const stringToColour = async (str) => { | ||
const msgBuffer = new TextEncoder().encode(str) | ||
// hash the message | ||
const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer) | ||
// convert ArrayBuffer to Array | ||
const hashArray = Array.from(new Uint8Array(hashBuffer)) | ||
// convert bytes to hex string | ||
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, '0')).join('') | ||
return `#${hashHex.slice(0, 6)}` | ||
var hash = 0 | ||
for (var i = 0; i < str.length; i++) { | ||
hash = str.charCodeAt(i) + ((hash << 5) - hash) | ||
} | ||
var color = '#' | ||
for (var i = 0; i < 3; i++) { | ||
var value = (hash >> (i * 8)) & 0xff | ||
color += ('00' + value.toString(16)).substr(-2) | ||
} | ||
console.log('colour', color) | ||
return color | ||
} | ||
@@ -40,0 +40,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2350904
5092