UNPKG

visualise-elastic-profile

Version:

Visualise results from Profile API of ElasticSearch on the command line

27 lines 852 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getColor = void 0; function hashCode(str) { let hash = 0; for (var i = 0; i < str.length; i++) { hash = str.charCodeAt(i) + ((hash << 5) - hash); } return hash; } function hslToHex(hue, saturation, luminance) { luminance /= 100; const a = (saturation * Math.min(luminance, 1 - luminance)) / 100; const toHex = (n) => { const k = (n + hue / 30) % 12; const color = luminance - a * Math.max(Math.min(k - 3, 9 - k, 1), -1); return Math.round(255 * color) .toString(16) .padStart(2, '0'); }; return `#${toHex(0)}${toHex(8)}${toHex(4)}`; } function getColor(str) { return hslToHex(hashCode(str) % 360, 100, 20); } exports.getColor = getColor; //# sourceMappingURL=color.js.map