UNPKG

@patreon/studio

Version:

Patreon Studio Design System

14 lines 554 B
export function isHexColor(color) { return color.startsWith('#'); } /** convert a string to a stable hash */ function stringToHash(str) { return String(Array.from(str) // the `| 0` part forces h to be a 32-bit number // eslint-disable-next-line no-bitwise .reduce((s, c) => (Math.imul(31, s) + c.charCodeAt(0)) | 0, 0)); } export function getCacheKey({ inputColor, tokenMap }) { return `${inputColor.replace('#', '')}-${stringToHash(JSON.stringify(tokenMap).slice(0, 500))}`; } //# sourceMappingURL=color-system.js.map