UNPKG

@thi.ng/imgui

Version:

Immediate mode GUI with flexible state handling & data only shape output

21 lines (20 loc) 579 B
import { hash } from "@thi.ng/vectors/hash"; const BUF = new Array(1024); const encodeString = (txt, buf = BUF) => { const n = buf.length = txt.length; for (let i = 0; i < n; i++) { buf[i] = txt.charCodeAt(i); } return buf; }; const hashString = (txt) => hash(encodeString(txt)); const mixHash = (key, txt) => key ^ hashString(txt); const labelHash = (key, label, disabled) => mixHash(key + ~~disabled, label); const valHash = (key, val, disabled) => mixHash(key + ~~disabled, String(val)); export { encodeString, hashString, labelHash, mixHash, valHash };