UNPKG

@crazy-web/feedback

Version:

A feedback form handler package that shows a popup based on allowed URLs.

20 lines (19 loc) 615 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.generateRandomColors = void 0; const generateRandomColors = ({ string = "" }) => { let hash = 0; let i; /* eslint-disable no-bitwise */ for (i = 0; i < string.length; i += 1) { hash = string.charCodeAt(i) + ((hash << 5) - hash); } let color = '#'; for (i = 0; i < 3; i += 1) { const value = (hash >> (i * 8)) & 0xff; color += `00${value.toString(16)}`.slice(-2); } /* eslint-enable no-bitwise */ return color; }; exports.generateRandomColors = generateRandomColors;