/**
* Detect if string is a color
**/
function isColor (str) {
const style = new Option().style
style.color = str
return style.color === str
}
/**
* Calculate a 32 bit FNV-1a hash
*
* @param {string} str the input value
* @param {boolean} [asString=false] optionally set to true to return the hash value as
* 8-digit hex string instead of an integer
* @param {integer} [seed=0x811c9dc5] optionally pass the hash of the previous chunk
* @returns {integer | string}
*/
function hashFnv32a(str, asString = false, seed = 0x811c9dc5) {
let hval = seed
for (let i = 0; i < str.length; i++) {
hval ^= str.charCodeAt(i)
hval += (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24)
}
if (asString) {
// Convert to 8 digit hex string
return ('0000000' + (hval >>> 0).toString(16)).substr(-8)
}
return hval >>> 0
}