UNPKG

@amaui/utils

Version:
14 lines (13 loc) 436 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const stringToColor = (value) => { let hash = 0; value.split('').forEach(item => hash = item.charCodeAt(0) + ((hash << 5) - hash)); let color = '#'; for (let i = 0; i < 3; i++) { const value_ = (hash >> (i * 8)) & 0xff; color += value_.toString(16).padStart(2, '0'); } return color; }; exports.default = stringToColor;